dart-lang/chromedeveditor — pull request #3348 by rpaquay (2014-09-08 16:01:23+00:00)
Title: Update cde to use Polymer 0.13.0.

Upgrade to polymer 0.13.0+3.

There was an issue where CDE would not starting up properly (infinite spinning wheel) when upgrading from polymer 0.12. The root cause was that we were not registering the "spark-icon" element even though we use it (transitively from spark-button) in the main CDE page.

The chain of events that lead to this problem was as follows:

* The Polymer.onReady future was never "completed", so cde would not finish initialization and switch to the main UI. He is the cde code:

return polymer.Polymer.onReady.then((_) {
spark.uiReady();
return spark.init();
});

* It seems (not 100% sure) out that "onReady" is called when the "polymer-ready" event is fired.

whenPolymerReady(function() {
document.body.removeAttribute('unresolved');
document.dispatchEvent(
new CustomEvent('polymer-ready', {bubbles: true})
);
});

* The definition of "whenPolymerReady" is as follows:

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

This means that "callback" (the function that fires the "polymer-ready" event) is called when the "queue" object is ready.

* The "queue.check()" function does the following:

check: function() {
(...)
if (this.canReady()) {
this.ready();
return true;
}
},

* the "canReady()" function was never returning "true", hence the event was never fired.

canReady: function() {
return !this.waitToReady && this.isEmpty();
},

* the "isEmpty" function was never returning true because the "elements" array contained at least one element with a "queue.flushable" to false.

isEmpty: function() {
for (var i=0, l=elements.length, e; (i