Multiple update
s for an element may run during parsing depending on script type
#258
Closed
3 of 6 tasks
Description
If an element definition is loaded synchronously with a legacy script,
update
may be called multiple times for any main-document elements that follow the script in the page: one for any defaults set in theconstructor
, plus one for eachattributeChangedCallback
.If an element definition is loaded using defer semantics (e.g.
type="module"
ordefer
),update
is only called once for such elements.The assumption that one microtask is enough to collect the constructor defaults and overrides via attributes appears to be insufficient in the first case above.
Live Demo
Note console logging:
It appears we need to add back the optimization (used in Polymer 2) to not flush property changes (e.g. the initial
_validate
->update
->render
) until the element has been connected, to ensure efficient startup of the element and avoid spamming the update/render lifecycles.Applying the following stopgap
DeferUntilConnected
mixin demonstrates the expected improvements, but ideallychangedProperties
should accumulate until the actualupdate
, which this does not attempt: code, demoBrowsers Affected
Versions
The text was updated successfully, but these errors were encountered: