Skip to content

Commit

Permalink
Merge branch 'master' into closure-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed May 23, 2017
2 parents 7abd703 + 7d5e448 commit db38807
Show file tree
Hide file tree
Showing 19 changed files with 1,422 additions and 212 deletions.
375 changes: 375 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "polymer",
"version": "2.0.0-rc.7",
"main": [
"polymer.html"
],
Expand All @@ -21,8 +20,8 @@
"url": "https://github.com/Polymer/polymer.git"
},
"dependencies": {
"shadycss": "webcomponents/shadycss#^v1.0.0-rc.1",
"webcomponentsjs": "^v1.0.0-rc.5"
"shadycss": "webcomponents/shadycss#^v1.0.0",
"webcomponentsjs": "^v1.0.0"
},
"devDependencies": {
"web-component-tester": "^v6.0.0-prerelease.10",
Expand Down
2 changes: 1 addition & 1 deletion lib/elements/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
for (let n=this.root.firstChild; n; n=n.nextSibling) {
this.__children[this.__children.length] = n;
}
this._flushProperties();
this._enableProperties();
}
this.__insertChildren();
this.dispatchEvent(new CustomEvent('dom-change', {
Expand Down
72 changes: 6 additions & 66 deletions lib/mixins/element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@
*/
_initializeProperties() {
Polymer.telemetry.instanceCount++;
hostStack.registerHost(this);
this.constructor.finalize();
const importPath = this.constructor.importPath;
// note: finalize template when we have access to `localName` to
Expand Down Expand Up @@ -631,9 +630,7 @@
if (window.ShadyCSS && this._template) {
window.ShadyCSS.styleElement(this);
}
if (!this.__dataInitialized) {
this._flushProperties();
}
this._enableProperties();
}

/**
Expand All @@ -651,9 +648,7 @@
*/
ready() {
if (this._template) {
hostStack.beginHosting(this);
this.root = this._stampTemplate(this._template);
hostStack.endHosting(this);
this.$ = this.root.$;
}
super.ready();
Expand All @@ -669,10 +664,14 @@
* @override
*/
_readyClients() {
super._readyClients();
if (this._template) {
this.root = this._attachDom(this.root);
}
// The super._readyClients here sets the clients initialized flag.
// We must wait to do this until after client dom is created/attached
// so that this flag can be checked to prevent notifications fired
// during this process from being handled before clients are ready.
super._readyClients();
}


Expand Down Expand Up @@ -786,65 +785,6 @@
return PolymerElement;
});

/**
* Helper api for enqueing client dom created by a host element.
*
* By default elements are flushed via `_flushProperties` when
* `connectedCallback` is called. Elements attach their client dom to
* themselves at `ready` time which results from this first flush.
* This provides an ordering guarantee that the client dom an element
* creates is flushed before the element itself (i.e. client `ready`
* fires before host `ready`).
*
* However, if `_flushProperties` is called *before* an element is connected,
* as for example `Templatize` does, this ordering guarantee cannot be
* satisfied because no elements are connected. (Note: Bound elements that
* receive data do become enqueued clients and are properly ordered but
* unbound elements are not.)
*
* To maintain the desired "client before host" ordering guarantee for this
* case we rely on the "host stack. Client nodes registers themselves with
* the creating host element when created. This ensures that all client dom
* is readied in the proper order, maintaining the desired guarantee.
*
* @private
*/
let hostStack = {

stack: [],

/**
* @param {*} inst Instance
* @this {hostStack}
*/
registerHost(inst) {
if (this.stack.length) {
let host = this.stack[this.stack.length-1];
host._enqueueClient(inst);
}
},

/**
* @param {*} inst Instance
* @this {hostStack}
*/
beginHosting(inst) {
this.stack.push(inst);
},

/**
* @param {*} inst Instance
* @this {hostStack}
*/
endHosting(inst) {
let stackLen = this.stack.length;
if (stackLen && this.stack[stackLen-1] == inst) {
this.stack.pop();
}
}

}

/**
* Provides basic tracking of element definitions (registrations) and
* instance counts.
Expand Down
36 changes: 23 additions & 13 deletions lib/mixins/property-accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
_initializeProperties() {
this.__serializing = false;
this.__dataCounter = 0;
this.__dataEnabled = false;
this.__dataInitialized = false;
this.__dataInvalid = false;
this.__data = {};
Expand Down Expand Up @@ -470,21 +471,36 @@
}
}

/**
* Call to enable property accessor processing. Before this method is
* called accessor values will be set but side effects are
* queued. When called, any pending side effects occur immediately.
* For elements, generally `connectedCallback` is a normal spot to do so.
* It is safe to call this method multiple times as it only turns on
* property accessors once.
*/
_enableProperties() {
if (!this.__dataEnabled) {
this.__dataEnabled = true;
if (this.__dataInstanceProps) {
this._initializeInstanceProperties(this.__dataInstanceProps);
this.__dataInstanceProps = null;
}
this.ready()
}
}

/**
* Calls the `_propertiesChanged` callback with the current set of
* pending changes (and old values recorded when pending changes were
* set), and resets the pending set of changes.
* set), and resets the pending set of changes. Generally, this method
* should not be called in user code.
*
* Note that this method must be called once to enable the property
* accessors system. For elements, generally `connectedCallback`
* is a normal spot to do so.
*
* @protected
*/
_flushProperties() {
if (!this.__dataInitialized) {
this.ready()
} else if (this.__dataPending) {
if (this.__dataPending) {
let changedProps = this.__dataPending;
this.__dataPending = null;
this.__dataCounter++;
Expand All @@ -508,12 +524,6 @@
* @public
*/
ready() {
// Update instance properties that shadowed proto accessors; these take
// priority over any defaults set in constructor or attributeChangedCallback
if (this.__dataInstanceProps) {
this._initializeInstanceProperties(this.__dataInstanceProps);
this.__dataInstanceProps = null;
}
this.__dataInitialized = true;
// Run normal flush
this._flushProperties();
Expand Down
Loading

0 comments on commit db38807

Please sign in to comment.