From 3da8910da34fba3702bc78f083240cbb7c925369 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Thu, 14 Nov 2013 18:30:46 -0800 Subject: [PATCH] =?UTF-8?q?Unresolved=20attribute=20available=20as=20a=20f?= =?UTF-8?q?eature=20of=20platform.=20With=20native=20imports,=20this=20sho?= =?UTF-8?q?uld=20be=20able=20to=20be=20removed.=20It=E2=80=99s=20needed=20?= =?UTF-8?q?because=20HTMLImports=20does=20not=20properly=20polyfill=20load?= =?UTF-8?q?ing=20imports=20before=20paint.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.json | 1 + platform.js | 3 ++- src/unresolved.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/unresolved.js 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