ibm-js / delite

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

fix deliver() for native props on chrome #389

Closed wkeese closed 9 years ago

wkeese commented 9 years ago

On Chrome and old iOS etc., we track updates to native properties via MutationObserver. This means that we hear about the updates asynchronously, even if the app calls deliver().

As a corollary, initial processing for parameters like value in new Switch({value: ...}) also happen asynchronously, even though deliver() is called on creation. (Inconsistently, we handle <d-switch value=....> synchronously.)

I think this can be fixed by using the code in CustomElement#createdCallback():

// Call custom setters for initial values of attributes with shadow properties (dir, tabIndex, etc)
attrs.forEach(function (attrName) {
    if (this.hasAttribute(attrName)) { // initial value was specified
        var value = this.getAttribute(attrName);
        this.removeAttribute(attrName);
        setterMap[attrName].call(this, value); // call custom setter
    }
}, this);

And doing it also/instead in deliver().

Then clean up setTimeout() "workarounds" in test files like deliteful/tests/unit/ToggleButton.js.