Opened 8 years ago

Closed 8 years ago

#13193 closed defect (wontfix)

set()-ing on widgets before buildRendering()

Reported by: Mark Wubben Owned by: bill
Priority: high Milestone: 1.7
Component: Dijit Version: 1.7.0b1
Keywords: Cc:
Blocked By: Blocking:

Description

In dijit/_Widgetbase, calling set() before the domNode is available causes an error to be thrown. The code should test for domNode before trying to use it, see <https://github.com/EqualMedia/dijit/commit/ac4b8f14fd0d4f78c26f8a831fb7ec1afe803762> for a fix.

Change History (5)

comment:1 Changed 8 years ago by ben hockey

you're probably already aware but fwiw, setters are automatically called between buildRendering and postCreate if the domNode exists https://github.com/EqualMedia/dijit/blob/ac4b8f14fd0d4f78c26f8a831fb7ec1afe803762/_WidgetBase.js#L285

i'm curious... what is the use case that gets you into that branch of set before buildRendering?

comment:2 Changed 8 years ago by Mark Wubben

I'm building widgets on a new internal rendering stack, which has some subtle changes in widget lifecycle.

In this case I'm writing a textbox validation widget. I need to run the validation on the initial value before rendering, so it renders the widget correctly on the first go. (Although the rendering stack is reactive so it would update the DOM if I validate after the initial rendering.) Running the validator causes a few properties to be set, which fails if the widget hasn't rendered yet.

comment:3 Changed 8 years ago by Douglas Hays

Owner: changed from wkeese to bill

comment:4 Changed 8 years ago by bill

Component: GeneralDijit

Hmm, well in general set() won't work before buildRendering() as it can call any number of custom setters that depend on the DOM existing. The code you modified is for one particular case, the attribute to DOM mapping code (nee attributeMap).

I checked your patch. It's a small change, but since it doesn't "fix" set() in general does it really fix your issue?

The other thing is that if the attribute to DOM code is executed before the DOM exists, it won't do anything, so (unless your widget has special code) the attribute values will never get reflected into the widget's DOM.

comment:5 Changed 8 years ago by Mark Wubben

Resolution: wontfix
Status: newclosed

Hmm, well in general set() won't work before buildRendering() as it can call any number of custom setters that depend on the DOM existing. The code you modified is for one particular case, the attribute to DOM mapping code (nee attributeMap). The other thing is that if the attribute to DOM code is executed before the DOM exists, it won't do anything, so (unless your widget has special code) the attribute values will never get reflected into the widget's DOM.

Actually this is a key part. All DOM ought to be managed by our rendering stack, I might have to override some of those Dijit bits for our widgets. I get the point of set() only being applicable after buildRendering(), so this change actually makes that murkier. I'll look for a different solution.

Note: See TracTickets for help on using tickets.