Skip to content

Commit

Permalink
Merge branch 'master' into 2.x-disable-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Mar 21, 2017
2 parents 1b4a978 + 8c1a576 commit a5c143d
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polymer",
"version": "2.0.0-rc.2",
"version": "2.0.0-rc.3",
"main": [
"polymer.html"
],
Expand Down
18 changes: 4 additions & 14 deletions lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
registered: true,
attributeChanged: true,
// meta objects
behaviors: true,
hostAttributes: true,
properties: true,
observers: true,
listeners: true
behaviors: true
}

/**
Expand Down Expand Up @@ -135,8 +131,6 @@

function GenerateClassFromInfo(info, Base) {

let registered = false;

class PolymerGenerated extends Base {

static get properties() {
Expand Down Expand Up @@ -167,13 +161,9 @@
}

_registered() {
if (!registered) {
super._registered();
// call `registered` only if it was not called for *this* constructor
registered = true;
if (info.registered) {
info.registered.call(Object.getPrototypeOf(this));
}
super._registered();
if (info.registered) {
info.registered.call(Object.getPrototypeOf(this));
}
}

Expand Down
9 changes: 7 additions & 2 deletions lib/legacy/legacy-element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,17 @@

/**
* Overrides the default `Polymer.PropertyEffects` implementation to
* add support for one-time `registration` callback.
* add support for class initialization via the `_registered` callback.
* This is called only when the first instance of the element is created.
*
* @override
*/
_initializeProperties() {
this._registered();
let proto = Object.getPrototypeOf(this);
if (!proto.hasOwnProperty('__hasRegisterFinished')) {
proto.__hasRegisterFinished = true;
this._registered();
}
super._initializeProperties();
}

Expand Down
4 changes: 1 addition & 3 deletions lib/utils/mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
Polymer.dedupingMixin = function(mixin) {
mixin = cachingMixin(mixin);
// maintain a unique id for each mixin
if (!mixin.__id) {
mixin.__dedupeId = ++dedupeId;
}
mixin.__dedupeId = ++dedupeId;
return function(base) {
let baseSet = base.__mixinSet;
if (baseSet && baseSet[mixin.__dedupeId]) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polymer/polymer",
"version": "2.0.0-rc.2",
"version": "2.0.0-rc.3",
"description": "The Polymer library makes it easy to create your own web components. Give your element some markup and properties, and then use it on a site. Polymer provides features like dynamic templates and data binding to reduce the amount of boilerplate you need to write",
"main": "polymer.html",
"directories": {
Expand Down
15 changes: 14 additions & 1 deletion test/unit/behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@

behaviors: [
Polymer.BehaviorA
]
],

properties: {},
observers: [],
hostAttributes: {},
listeners: {}
});

Polymer({
Expand Down Expand Up @@ -307,6 +312,14 @@
assert.equal(el.is, 'single-behavior');
});

test('instance behaviors, properties, observers, hostAttributes, listeners', function() {
assert.isOk(el.behaviors);
assert.isOk(el.properties);
assert.isOk(el.observers);
assert.isOk(el.hostAttributes);
assert.isOk(el.listeners);
});

test('ready from behavior', function() {
assert.equal(el.__readyA, true);
});
Expand Down
24 changes: 22 additions & 2 deletions test/unit/mixin-behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,18 @@
BehaviorRegistered.prototype.registeredCount = 0;

customElements.define(BehaviorRegistered.is, BehaviorRegistered);

class BehaviorRegisteredExt extends BehaviorRegistered {
static get is() { return 'behavior-registered-ext'}
}

BehaviorRegisteredExt.prototype.registeredCount = 0;

customElements.define(BehaviorRegisteredExt.is, BehaviorRegisteredExt);
});
</script>
</dom-module>

</script>

<test-fixture id="single">
<template>
<single-behavior></single-behavior>
Expand Down Expand Up @@ -364,6 +370,12 @@
<behavior-registered></behavior-registered>
</template>
</test-fixture>

<test-fixture id="registered-ext">
<template>
<behavior-registered-ext></behavior-registered-ext>
</template>
</test-fixture>
<script>

suite('single behavior element', function() {
Expand Down Expand Up @@ -421,6 +433,14 @@
assert.deepEqual(el.registeredProps, [true, true, true]);
});

test('extending element with behaviors with registered properly registers', function() {
var el = fixture('registered-ext');
assert.equal(el.registeredCount, 4);
assert.equal(el.registeredBehaviors.length, 3);
assert.equal(el.registeredBehaviors, el.behaviors);
assert.deepEqual(el.registeredProps, [true, true, true]);
});

});

suite('behavior lifecycle', function() {
Expand Down

0 comments on commit a5c143d

Please sign in to comment.