Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

multi and fallback-selection cause the initial property flush to throw when set as attributes in HTML. #176

@bicknellr

Description

@bicknellr

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

  • Chrome
  • Firefox
  • Safari 11
  • Edge

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions