Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
simplify CustomElements polyfill upgrade optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Aug 8, 2014
1 parent 56417b5 commit 584d899
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/declaration/polymer-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
var extend = scope.extend;
var api = scope.api;
var queue = scope.queue;
var whenPolymerReady = scope.whenPolymerReady;
var whenReady = scope.whenReady;
var getRegisteredPrototype = scope.getRegisteredPrototype;
var waitingForPrototype = scope.waitingForPrototype;

Expand Down Expand Up @@ -124,7 +124,7 @@

// boot tasks

whenPolymerReady(function() {
whenReady(function() {
document.body.removeAttribute('unresolved');
document.dispatchEvent(
new CustomEvent('polymer-ready', {bubbles: true})
Expand Down
17 changes: 5 additions & 12 deletions src/declaration/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@
},

ready: function() {
this.flush();
// TODO(sorvell): As an optimization, turn off CE polyfill upgrading
// while registering. This way we avoid having to upgrade each document
// piecemeal per registration and can instead register all elements
// and upgrade once in a batch. Without this optimization, upgrade time
// degrades significantly when SD polyfill is used. This is mainly because
// querying the document tree for elements is slow under the SD polyfill.
if (CustomElements.ready === false) {
CustomElements.upgradeDocumentTree(document);
CustomElements.ready = true;
}
var polyfillWasReady = CustomElements.ready;
CustomElements.ready = false;
this.flush();
CustomElements.upgradeDocumentTree(document);
CustomElements.ready = polyfillWasReady;
Platform.flush();
requestAnimationFrame(this.flushReadyCallbacks);
},
Expand Down Expand Up @@ -178,15 +178,8 @@
return importQueue.length ? importQueue[0] : mainQueue[0];
}

var polymerReadied = false;

document.addEventListener('WebComponentsReady', function() {
CustomElements.ready = false;
});

function whenPolymerReady(callback) {
queue.waitToReady = true;
CustomElements.ready = false;
HTMLImports.whenImportsReady(function() {
queue.addReadyCallback(callback);
queue.waitToReady = false;
Expand Down

0 comments on commit 584d899

Please sign in to comment.