Skip to content

Commit

Permalink
add controller styles synchronously; Polymer.installControllerStyles …
Browse files Browse the repository at this point in the history
…should be called in inserted.
  • Loading branch information
sorvell committed Jun 14, 2013
1 parent 597bd0d commit 1afbc0a
Showing 1 changed file with 8 additions and 37 deletions.
45 changes: 8 additions & 37 deletions src/styling.js
Expand Up @@ -85,15 +85,13 @@
STYLE_CONTROLLER_SCOPE);
}
var styleElement = elementElement.controllerStyle;
async.queue(function() {
var scope = findStyleController(element);
// apply controller styles only if they are not yet applied
if (scope && !scopeHasElementStyle(scope, element,
STYLE_CONTROLLER_SCOPE)) {
Polymer.shimPolyfillDirectives([styleElement], element.localName);
applyStyleToScope(styleElement, scope);
}
});
var scope = findStyleController(element);
// apply controller styles only if they are not yet applied
if (scope && !scopeHasElementStyle(scope, element,
STYLE_CONTROLLER_SCOPE)) {
Polymer.shimPolyfillDirectives([styleElement], element.localName);
applyStyleToScope(styleElement, scope);
}
}

function scopeHasElementStyle(scope, element, descriptor) {
Expand Down Expand Up @@ -145,33 +143,6 @@
}
return nodes.filter(matcher);
}


// queue a series of functions to occur async.
var async = {
list: [],
queue: function(inFn) {
if (inFn) {
async.list.push(inFn);
}
async.queueFlush();
},
queueFlush: function() {
if (!async.flushing) {
async.flushing = true;
requestAnimationFrame(async.flush);
}
},
flush: function() {
async.list.forEach(function(fn) {
fn();
});
async.list = [];
async.flushing = false;
}

}

function findStyleController(node) {
// find the shadow root that contains inNode
var n = node;
Expand All @@ -194,7 +165,7 @@
function applyStyleToScope(style, scope) {
if (style) {
var clone = style.cloneNode(true);
// TODO(sorvell): this is here for IE, which requires deep cloning
// TODO(sorvell): this is here for IE, which requires deep cloning
// of style elements.
// see https://github.com/Polymer/ShadowDOM/issues/165
if (window.ShadowDOMPolyfill) {
Expand Down

0 comments on commit 1afbc0a

Please sign in to comment.