iron-selector
iron-selector copied to clipboard
`multi` and `fallback-selection` cause the initial property flush to throw when set as attributes in HTML.
Description
When both the multi
and fallback-selection
attributes are set on an <iron-selector>
in HTML, the first property flush throws in IronMultiSelectableBehavior
.
When these two attributes are used together, the _checkFallback(fallbackSelection)
observer in IronSelectableBehavior
runs before the multiChanged
observer in IronMultiSelectableBehavior
. multiChanged
would normally update this._selection.multi
, which IronSelection
uses to determine whether or not to return the full array of selected items or just the first item. However, _checkFallback
is called first, which eventually calls down into _updateSelected
, which reads this.multi
and calls _selectMulti
. _selectMulti
assumes it's safe to consider the result of this._selection.get()
to be an array, but this._selection.multi
has not been updated yet and this._selection.get()
returns undefined
rather than an empty array, causing an error to be thrown on getting length
.
Expected outcome
The initial property flush succeeds without throwing.
Actual outcome
The initial property flush throws an error on the first connectedCallback
.
Live Demo
https://js-kt759o.stackblitz.io/ (https://stackblitz.com/edit/js-kt759o)
Steps to reproduce
In HTML <iron-selector>
with the multi
and fallback-selection
attributes set.
Browsers Affected
- [x] Chrome
- [x] Firefox
- [x] Safari 11
- [x] Edge