ibm-js / delite

HTML Custom Element / Widget infrastructure
http://ibm-js.github.io/delite/
Other
68 stars 28 forks source link

FormWidget: setAttribute() changes before deliver() can be lost. #452

Open wkeese opened 8 years ago

wkeese commented 8 years ago

Although FormWidget works properly for declarative creation and normal programmatic creation (new MyWidget({...})), setAttribute() after a register.createElement("my-widget") call won't be handled correctly:

var w = register.createElement("my-widget");
w.foo = 123;
w.setAttribute("aria-label", "...");

In this case the setAttribute() call occurs before the focusNode has been created, so presumably the setAttribute() call is a no-op.

The solution is presumably that in that case FormWidget#setAttribute() should just set the attribute on the root node, and then it will be moved to the correct node later, in FormWidget#postRender().

Note that the case below works fine since the DOM structure is created before the new returns:

var w = new MyWidget({ foo: 123 });
w.setAttribute("aria-label", "...");