diff --git a/build.json b/build.json index 41a2243..30c23c3 100644 --- a/build.json +++ b/build.json @@ -12,6 +12,7 @@ "src/dom.js", "src/template.js", "src/inspector.js", + "src/unresolved.js", "../polymer-expressions/build.json", "src/patches-mdv.js", "../HTMLImports/build.json", diff --git a/platform.js b/platform.js index 4951ca9..bbf5c55 100644 --- a/platform.js +++ b/platform.js @@ -39,7 +39,8 @@ function processFlags(flags) { 'src/lang.js', 'src/dom.js', 'src/template.js', - 'src/inspector.js' + 'src/inspector.js', + 'src/unresolved.js' ]; var MDV = [ diff --git a/src/unresolved.js b/src/unresolved.js new file mode 100644 index 0000000..09ed320 --- /dev/null +++ b/src/unresolved.js @@ -0,0 +1,59 @@ +/* + * Copyright 2013 The Polymer Authors. All rights reserved. + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file. + */ +(function(scope) { + /* + Shim :unresolved via an attribute unresolved. + TODO(sorvell): This is currently done once when the first + round of elements are upgraded. This is incorrect, and it will + need to be done dynamically. + The 'resolved' attribute is experimental and may be removed. + */ + var TRANSITION_TIME = 0.2; + var UNRESOLVED = 'unresolved'; + var RESOLVED = 'resolved'; + var UNRESOLVED_SELECTOR = '[' + UNRESOLVED + ']'; + var RESOLVED_SELECTOR = '[' + RESOLVED + ']'; + var style = document.createElement('style'); + + style.textContent = UNRESOLVED_SELECTOR + ' { ' + + 'opacity: 0; display: block; overflow: hidden; } \n' + + RESOLVED_SELECTOR + '{ display: block; overflow: hidden;\n' + + '-webkit-transition: opacity ' + TRANSITION_TIME + 's; ' + + 'transition: opacity ' + TRANSITION_TIME +'s; }\n'; + var head = document.querySelector('head'); + head.insertBefore(style, head.firstChild); + + // remove unresolved and apply resolved class + function resolveElements() { + requestAnimationFrame(function() { + var nodes = document.querySelectorAll(UNRESOLVED_SELECTOR); + for (var i=0, l=nodes.length, n; (i