mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Behavior property copying fixes
* ensure element has `is` on prototype early as this is sometimes checked in user code. * ensure properties copied onto elements from info/behaviors are forced to configurable so they can be re-configured by later behaviors. * add `_noAccessors` optimization for faster property copying
This commit is contained in:
@@ -379,6 +379,20 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
behaviors: [window.BehaviorA]
|
||||
});
|
||||
|
||||
Polymer({
|
||||
is: 'no-accessors-behavior',
|
||||
behaviors: [{
|
||||
_noAccessors: true,
|
||||
properties: {
|
||||
nug: String
|
||||
},
|
||||
foo: function() {},
|
||||
bar: true
|
||||
}],
|
||||
_noAccessors: true,
|
||||
zot: 'zot'
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<test-fixture id="single">
|
||||
@@ -447,6 +461,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="no-accessors-behavior">
|
||||
<template>
|
||||
<no-accessors-behavior></no-accessors-behavior>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script type="module">
|
||||
import { Polymer } from '../../polymer-legacy.js';
|
||||
|
||||
@@ -501,6 +521,15 @@ suite('single behavior element', function() {
|
||||
assert.notOk(el.listeners);
|
||||
});
|
||||
|
||||
test('properties on objects marked with `_noAccessors` are copied to class', function() {
|
||||
const el = fixture('no-accessors-behavior');
|
||||
assert.ok(el.foo);
|
||||
assert.isTrue(el.bar);
|
||||
assert.equal(el.zot, 'zot');
|
||||
el.setAttribute('nug', 'nug');
|
||||
assert.equal(el.nug, 'nug');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('behavior.registered', function() {
|
||||
|
||||
Reference in New Issue
Block a user