PolymerElements / iron-a11y-keys-behavior

A behavior that enables keybindings for greater a11y
24 stars 41 forks source link

this.behaviors property is not available in native 2.0 class-based element #69

Closed govis closed 7 years ago

govis commented 7 years ago

Description

Just tried upgrading an element to native 2.0 class-based syntax and used Polymer.mixinBehaviors to mix Polymer.PaperInputBehavior this way, which in turn mixes in additional behaviors including Polymer.IronA11yKeysBehavior.

Unfortunately it seems that Polymer.mixinBehaviorsis not setting element's this.behaviors property, which is used by Polymer.IronA11yKeysBehavior, so it fails with an Error TypeError: Cannot read property 'map' of undefined error

https://github.com/PolymerElements/iron-a11y-keys-behavior/blob/2.0-preview/iron-a11y-keys-behavior.html#L374

I am not sure if any other PolymerElements/Behaviors make use of this property and if a change to Polymer.mixinBehaviors is warranted to maintain backward compatibility with hybrid Polymer Elements' behaviors or we shall treat it as a breaking API change.

As it stands right now it appears that this issue will get in the way of moving any element with a dependency on Polymer.IronA11yKeysBehavior to Polymer 2.0 class-based syntax.

Expected outcome

No error

Actual outcome

Error TypeError: Cannot read property 'map' of undefined

https://github.com/PolymerElements/iron-a11y-keys-behavior/blob/2.0-preview/iron-a11y-keys-behavior.html#L374

Live Demo

http://jsbin.com/gisakayogu/edit?html,console,output

This just shows that this.behaviors is undefined

Steps to reproduce

  1. Run.
  2. look for 'undefined' logged to console.

Browsers Affected

valdrinkoshi commented 7 years ago

Closing as it got fixed in https://github.com/Polymer/polymer/issues/4397. Thanks for reporting this @govis!