PolymerElements / iron-selector

Manages a list of elements that can be selected
32 stars 55 forks source link

Nullref in iron-selectable during ready() initialization #134

Closed martijneken closed 8 years ago

martijneken commented 8 years ago

Description

On initialization, properties 'items' and 'selected' may be applied to an iron-selectable element in any order, by Polymer's _applyConfig method (code). If 'selected' is applied before 'items', a nullref occurs due to the _updateSelected observer.

Expected outcome

No nullref.

Actual outcome

Stack trace:

_valueToIndex (iron-selectable…th_deps.js:297)
_valueToItem (iron-selectable…th_deps.js:292)
_selectSelected (iron-selectable…th_deps.js:279)
_updateSelected (iron-selectable…th_deps.js:275)
_complexObserverEffect (main_devserver_…r_core.js:4419)
_effectEffects (main_devserver_…r_core.js:4252)
_propertySetter (main_devserver_…r_core.js:4236)
__setProperty (main_devserver_…r_core.js:4245)
_applyConfig (main_devserver_…r_core.js:4854)
_afterClientsReady (main_devserver_…r_core.js:4848)
_ready (main_devserver_…er_core.js:752)
_tryReady (main_devserver_…er_core.js:738)
_initFeatures (main_devserver_…r_core.js:6732)
createdCallback (main_devserver_…er_core.js:182)
window.Polymer (main_devserver_…mer_core.js:51)
(anonymous function) (iron-pages-html…with_deps.js:7)
(anonymous function) (main_devserver.js:561)

Live Demo

This is a failed attempt at repro (can't control property iteration order): http://jsbin.com/nafofokofe/edit?html,js,output

Steps to reproduce

Use an iron-pages element with a "selected" binding.

Browsers Affected

All?

I have a 2-line fix ready, will supply it shortly.

martijneken commented 8 years ago

This actually was indicative of a deeper problem in my BUILD. Elements were registering out of order, which broke data binding, which indirectly broke initialization.