| Summary: | Javascript engine gets confused, calls method on wrong object. | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | MikeB <mike.benoit> |
| Component: | WebCore JavaScript | Assignee: | Nobody <webkit-unassigned> |
| Status: | REOPENED --- | ||
| Severity: | Critical | CC: | achristensen, mark.lam, webkit-bug-importer, ysuzuki |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Mac | ||
| OS: | macOS 10.15 | ||
|
Description
MikeB
2020-05-27 17:47:52 PDT
> $this < PayrollRemittanceAgencyEventWizardStepHome {cid: "view247", el: k, tagName: "div", events: Object, $el: k, …} > $this.__proto__ < PayrollRemittanceAgencyEventWizardStepHome {on: function, listenTo: function, off: function, stopListening: function, once: function, …} > $this.__proto__.__proto__ < WizardStep {on: function, listenTo: function, off: function, stopListening: function, once: function, …} > $this.__proto__.__proto__.render < function render() { this.initCardsBlock(); return this._render(); } > $this.render < function render() { //do render stuff } > $this.hasOwnProperty('render') < true So, WizardStep#render is not called because $this has its own "render" function which is empty. And it is defined in PayrollRemittanceAgencyEventWizard.js. So, this is not related to ES6 class. This "render" function is defined at this point. initialize (TTBackboneView.js:24) initialize (WizardStep.js:24) (anonymous function) (backbone-min.js:967) TTBackboneView (TTBackboneView.js:17) WizardStep (WizardStep.js:20) PayrollRemittanceAgencyEventWizardStepHome (PayrollRemittanceAgencyEventWizardStepHome.js:12) Eval Code (Anonymous Script 1 (line 1)) (anonymous function) (Wizard.js:224) (anonymous function) (Global.js:1605) initStepObject (Wizard.js:219) initialize (Wizard.js:45) (anonymous function) (backbone-min.js:967) TTBackboneView (TTBackboneView.js:17) It seems that options["render"] is defined. This is https://bugs.webkit.org/show_bug.cgi?id=38970 Since Object.render is defined as non-enumerable property, for-in for PayrollRemittanceAgencyEventWizard is listing "render". You can avoid this issue if, 1. you define render etc. in Object with enumerable: false. Or 2. If options is truly a shallow option object, you can change TTBackboneView#initialize initialize( options ) { //Convert options object to this object properties as early as possible. if ( options && typeof options == 'object' ) { for ( const property in options ) { this[property] = options[property]; } } } to initialize( options ) { //Convert options object to this object properties as early as possible. if ( options && typeof options == 'object' ) { for ( const property in options ) { if (options.hasOwnProperty(property)) this[property] = options[property]; } } } *** This bug has been marked as a duplicate of bug 38970 *** (In reply to Yusuke Suzuki from comment #3) > This is https://bugs.webkit.org/show_bug.cgi?id=38970 > > Since Object.render is defined as non-enumerable property, for-in for > PayrollRemittanceAgencyEventWizard is listing "render". > > You can avoid this issue if, > > 1. you define render etc. in Object with enumerable: false. Object.prototype. > > Or > > 2. If options is truly a shallow option object, you can change > > TTBackboneView#initialize > > initialize( options ) { > //Convert options object to this object properties as early as possible. > if ( options && typeof options == 'object' ) { > for ( const property in options ) { > this[property] = options[property]; > } > } > } > > to > > initialize( options ) { > //Convert options object to this object properties as early as possible. > if ( options && typeof options == 'object' ) { > for ( const property in options ) { > if (options.hasOwnProperty(property)) > this[property] = options[property]; > } > } > } (In reply to Yusuke Suzuki from comment #5) > (In reply to Yusuke Suzuki from comment #3) > > This is https://bugs.webkit.org/show_bug.cgi?id=38970 > > > > Since Object.render is defined as non-enumerable property, for-in for > > PayrollRemittanceAgencyEventWizard is listing "render". > > > > You can avoid this issue if, > > > > 1. you define render etc. in Object with enumerable: false. > > Object.prototype. No, TTBackboneView.prototype.__proto__. This one has non-enumerable render etc. And it is inherited by PayrollRemittanceAgencyEventWizard. (In reply to Yusuke Suzuki from comment #6) > (In reply to Yusuke Suzuki from comment #5) > > (In reply to Yusuke Suzuki from comment #3) > > > This is https://bugs.webkit.org/show_bug.cgi?id=38970 > > > > > > Since Object.render is defined as non-enumerable property, for-in for > > > PayrollRemittanceAgencyEventWizard is listing "render". > > > > > > You can avoid this issue if, > > > > > > 1. you define render etc. in Object with enumerable: false. > > > > Object.prototype. > > No, TTBackboneView.prototype.__proto__. This one has non-enumerable render > etc. And it is inherited by PayrollRemittanceAgencyEventWizard. This is Backbone.View.prototype. Re-opening to investigate what looks like a networking issue that manifests with this test case. |