From 344ffeaae475babb529403f6608588a0fc73f4e7 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Fri, 12 Jul 2013 12:04:40 -0700 Subject: [PATCH 01/11] __instanceCreated no longer needed: - cloneNode upgrades - blink bug 229125 fixed --- src/patches-mdv.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/patches-mdv.js b/src/patches-mdv.js index 78167df..3bdab96 100644 --- a/src/patches-mdv.js +++ b/src/patches-mdv.js @@ -11,15 +11,6 @@ style.textContent = 'template {display: none !important;} /* injected by platfor var head = document.querySelector('head'); head.insertBefore(style, head.firstChild); -// MDV hook for processing created dom before bindings are made. We upgrade -// so custom elements get a chance to deal with bindings mdv is about to make. -HTMLTemplateElement.__instanceCreated = function(inNode) { - // TODO(sorvell): workaround for - // https://code.google.com/p/chromium/issues/detail?id=229125 - document.adoptNode(inNode); - CustomElements.upgradeAll(inNode); -}; - // dirtyCheck (with logging) function dirtyCheck() { logFlags.data && console.group("Model.dirtyCheck()"); From 1b95c2daf7fdc9e50f759ad5ad56c325fac0b943 Mon Sep 17 00:00:00 2001 From: "Scott J. Miles" Date: Wed, 17 Jul 2013 12:28:09 -0700 Subject: [PATCH 02/11] remove vestigial mdv code, tweak log --- src/patches-mdv.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/patches-mdv.js b/src/patches-mdv.js index 78167df..d588bea 100644 --- a/src/patches-mdv.js +++ b/src/patches-mdv.js @@ -11,18 +11,9 @@ style.textContent = 'template {display: none !important;} /* injected by platfor var head = document.querySelector('head'); head.insertBefore(style, head.firstChild); -// MDV hook for processing created dom before bindings are made. We upgrade -// so custom elements get a chance to deal with bindings mdv is about to make. -HTMLTemplateElement.__instanceCreated = function(inNode) { - // TODO(sorvell): workaround for - // https://code.google.com/p/chromium/issues/detail?id=229125 - document.adoptNode(inNode); - CustomElements.upgradeAll(inNode); -}; - // dirtyCheck (with logging) function dirtyCheck() { - logFlags.data && console.group("Model.dirtyCheck()"); + logFlags.data && console.group("Platform.performMicrotaskCheckpoint()"); check(); logFlags.data && console.groupEnd(); }; From aa95dd6b5956263f55fd6037aaa97f0171d86ed4 Mon Sep 17 00:00:00 2001 From: Scott Miles Date: Thu, 18 Jul 2013 14:53:33 -0700 Subject: [PATCH 03/11] expose polling interval handle --- src/patches-mdv.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/patches-mdv.js b/src/patches-mdv.js index d588bea..f9b6b4e 100644 --- a/src/patches-mdv.js +++ b/src/patches-mdv.js @@ -36,13 +36,14 @@ window.addEventListener('WebComponentsReady', function() { // dirty check periodically if platform does not have object observe. if (!Observer.hasObjectObserve) { - setInterval(check, dirtyCheckPollInterval); + dirtyPoll = setInterval(check, dirtyCheckPollInterval); } }); // exports scope.flush = dirtyCheck; +scope.dirtyPoll = dirtyPoll; // deprecated From 91faf992ccb4adbc0afe1b9cfbd42eb7bf8449a6 Mon Sep 17 00:00:00 2001 From: Scott Miles Date: Thu, 18 Jul 2013 16:39:23 -0700 Subject: [PATCH 04/11] really expose polling interval handle --- src/patches-mdv.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/patches-mdv.js b/src/patches-mdv.js index f9b6b4e..a7eb599 100644 --- a/src/patches-mdv.js +++ b/src/patches-mdv.js @@ -36,14 +36,13 @@ window.addEventListener('WebComponentsReady', function() { // dirty check periodically if platform does not have object observe. if (!Observer.hasObjectObserve) { - dirtyPoll = setInterval(check, dirtyCheckPollInterval); + scope.dirtyPoll = setInterval(check, dirtyCheckPollInterval); } }); // exports scope.flush = dirtyCheck; -scope.dirtyPoll = dirtyPoll; // deprecated From 5c8d0e8a2267add8af030bbfd1217a5743d1b8d2 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Mon, 22 Jul 2013 09:41:30 -0700 Subject: [PATCH 05/11] correct docs with updated setting name. --- src/ShadowCSS.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ShadowCSS.js b/src/ShadowCSS.js index bb59b6e..28e49df 100644 --- a/src/ShadowCSS.js +++ b/src/ShadowCSS.js @@ -57,7 +57,7 @@ becomes: - Alternatively, if Polymer.strictPolyfillStyling is set to true then + Alternatively, if Platform.ShadowCSS.strictStyling is set to true then selectors are scoped by adding an attribute selector suffix to each simple selector that contains the host element tag name. Each element in the element's ShadowDOM template is also given the scope attribute. From 160cf93ccdbc0f7b3f0e2c7cbf50bf06c43fb388 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Mon, 22 Jul 2013 18:20:19 -0700 Subject: [PATCH 06/11] ensure shadowRoots have .host and .olderShadowRoot references; automatically watch native shadowRoots for CustomElements. --- src/patches-shadowdom-native.js | 10 ++++++++++ src/patches-shadowdom-polyfill.js | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/patches-shadowdom-native.js b/src/patches-shadowdom-native.js index 5518bba..bf01ae2 100644 --- a/src/patches-shadowdom-native.js +++ b/src/patches-shadowdom-native.js @@ -15,6 +15,16 @@ window.wrap = window.unwrap = function(n){ return n; } + + var originalCreateShadowRoot = HTMLElement.prototype.webkitCreateShadowRoot; + HTMLElement.prototype.webkitCreateShadowRoot = function() { + var elderRoot = this.webkitShadowRoot; + var root = originalCreateShadowRoot.call(this); + root.olderShadowRoot = elderRoot; + root.host = this; + CustomElements.watchShadow(this); + return root; + } Object.defineProperties(HTMLElement.prototype, { shadowRoot: { diff --git a/src/patches-shadowdom-polyfill.js b/src/patches-shadowdom-polyfill.js index 89d2379..52d5029 100644 --- a/src/patches-shadowdom-polyfill.js +++ b/src/patches-shadowdom-polyfill.js @@ -43,6 +43,14 @@ } } }); + + // include .host reference + var originalCreateShadowRoot = HTMLElement.prototype.createShadowRoot; + HTMLElement.prototype.createShadowRoot = function() { + var root = originalCreateShadowRoot.call(this); + root.host = this; + return root; + } //TODO(sjmiles): review method alias with Arv HTMLElement.prototype.webkitCreateShadowRoot = From a69e476742410660f048f8bb49c16c5057970b9a Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Tue, 23 Jul 2013 15:13:41 -0700 Subject: [PATCH 07/11] Revert "collapse platform.debug.js into platform.js" This reverts commit 7b5a11978a960ebd1829d8f0af519265da44c16b. Conflicts: platform.js --- platform.debug.js | 72 +++++++++++++++++++++++++++++++++++++++++++++++ platform.js | 45 +---------------------------- 2 files changed, 73 insertions(+), 44 deletions(-) create mode 100644 platform.debug.js diff --git a/platform.debug.js b/platform.debug.js new file mode 100644 index 0000000..23c9bde --- /dev/null +++ b/platform.debug.js @@ -0,0 +1,72 @@ +/* + * 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) { + +// imports + +var flags = scope.flags; +var base = scope.basePath; + +// truthy value for any of these flags or failure to detect native +// shadowDOM results in polyfill +flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill || + !HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill'; + +// module dependencies + +var ShadowDOMNative = [ + 'lib/patches-shadowdom-native.js' +]; + +var ShadowDOMPolyfill = [ + '../ShadowDOM/shadowdom.js', + 'lib/patches-shadowdom-polyfill.js' +]; + +var Lib = [ + 'lib/lang.js', + 'lib/dom.js', + 'lib/template.js', + 'lib/inspector.js', +]; + +var MDV = [ + '../mdv/mdv.js', + 'lib/patches-mdv.js' +]; + +var Pointer = [ + '../PointerGestures/pointergestures.js' +]; + +var WebElements = [ + '../HTMLImports/html-imports.js', + '../CustomElements/custom-elements.js', + 'lib/patches-custom-elements.js' +]; + +// select ShadowDOM impl + +var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative; + +// construct active dependency list + +modules = [].concat( + ShadowDOM, + Lib, + WebElements, + Pointer, + MDV +); + +// write script tags for dependencies + +modules.forEach(function(inSrc) { + document.write(''); +}); + +})(Platform); diff --git a/platform.js b/platform.js index 2571789..4484719 100644 --- a/platform.js +++ b/platform.js @@ -9,51 +9,8 @@ var thisFile = 'platform.js'; var scopeName = 'Platform'; -// module dependencies - -var ShadowDOMNative = [ - 'src/patches-shadowdom-native.js' -]; - -var ShadowDOMPolyfill = [ - '../ShadowDOM/shadowdom.js', - 'src/patches-shadowdom-polyfill.js', - 'src/ShadowCSS.js' -]; - -var Lib = [ - 'src/lang.js', - 'src/dom.js', - 'src/template.js', - 'src/inspector.js', -]; - -var MDV = [ - '../mdv/mdv.js', - 'src/patches-mdv.js' -]; - -var Pointer = [ - '../PointerGestures/pointergestures.js' -]; - -var WebElements = [ - '../HTMLImports/html-imports.js', - '../CustomElements/custom-elements.js', - 'src/patches-custom-elements.js' -]; - function processFlags(flags) { - flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill || - !HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill'; - var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative; - this.modules = [].concat( - ShadowDOM, - Lib, - WebElements, - Pointer, - MDV - ); + this.modules = [flags.debug ? 'platform.debug.js' : 'platform.min.js']; } // export From e42cf6221af17075023e89f1c5b9b040f8003f48 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Tue, 23 Jul 2013 18:45:13 -0700 Subject: [PATCH 08/11] use src instead of lib folder name in platform.debug.js --- platform.debug.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/platform.debug.js b/platform.debug.js index 23c9bde..eb4ce46 100644 --- a/platform.debug.js +++ b/platform.debug.js @@ -19,24 +19,24 @@ flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill || // module dependencies var ShadowDOMNative = [ - 'lib/patches-shadowdom-native.js' + 'src/patches-shadowdom-native.js' ]; var ShadowDOMPolyfill = [ '../ShadowDOM/shadowdom.js', - 'lib/patches-shadowdom-polyfill.js' + 'src/patches-shadowdom-polyfill.js' ]; var Lib = [ - 'lib/lang.js', - 'lib/dom.js', - 'lib/template.js', - 'lib/inspector.js', + 'src/lang.js', + 'src/dom.js', + 'src/template.js', + 'src/inspector.js', ]; var MDV = [ '../mdv/mdv.js', - 'lib/patches-mdv.js' + 'src/patches-mdv.js' ]; var Pointer = [ @@ -46,7 +46,7 @@ var Pointer = [ var WebElements = [ '../HTMLImports/html-imports.js', '../CustomElements/custom-elements.js', - 'lib/patches-custom-elements.js' + 'src/patches-custom-elements.js' ]; // select ShadowDOM impl From 0209bc93c7b8a9740285554d4124bdbb8d4e7a9a Mon Sep 17 00:00:00 2001 From: frankiefu Date: Thu, 25 Jul 2013 16:41:00 -0700 Subject: [PATCH 09/11] add ShadowCSS.js back to platform.debug.js --- platform.debug.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform.debug.js b/platform.debug.js index eb4ce46..9c68ae7 100644 --- a/platform.debug.js +++ b/platform.debug.js @@ -24,7 +24,8 @@ var ShadowDOMNative = [ var ShadowDOMPolyfill = [ '../ShadowDOM/shadowdom.js', - 'src/patches-shadowdom-polyfill.js' + 'src/patches-shadowdom-polyfill.js', + 'src/ShadowCSS.js' ]; var Lib = [ From 94b6f1cedbf71274fc1a407da3ff8d6da53da75e Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 31 Jul 2013 12:07:04 -0700 Subject: [PATCH 10/11] only have a debug loader for platform --- platform.debug.js | 73 ----------------------------------------------- platform.js | 59 ++++++++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 79 deletions(-) delete mode 100644 platform.debug.js diff --git a/platform.debug.js b/platform.debug.js deleted file mode 100644 index 9c68ae7..0000000 --- a/platform.debug.js +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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) { - -// imports - -var flags = scope.flags; -var base = scope.basePath; - -// truthy value for any of these flags or failure to detect native -// shadowDOM results in polyfill -flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill || - !HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill'; - -// module dependencies - -var ShadowDOMNative = [ - 'src/patches-shadowdom-native.js' -]; - -var ShadowDOMPolyfill = [ - '../ShadowDOM/shadowdom.js', - 'src/patches-shadowdom-polyfill.js', - 'src/ShadowCSS.js' -]; - -var Lib = [ - 'src/lang.js', - 'src/dom.js', - 'src/template.js', - 'src/inspector.js', -]; - -var MDV = [ - '../mdv/mdv.js', - 'src/patches-mdv.js' -]; - -var Pointer = [ - '../PointerGestures/pointergestures.js' -]; - -var WebElements = [ - '../HTMLImports/html-imports.js', - '../CustomElements/custom-elements.js', - 'src/patches-custom-elements.js' -]; - -// select ShadowDOM impl - -var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative; - -// construct active dependency list - -modules = [].concat( - ShadowDOM, - Lib, - WebElements, - Pointer, - MDV -); - -// write script tags for dependencies - -modules.forEach(function(inSrc) { - document.write(''); -}); - -})(Platform); diff --git a/platform.js b/platform.js index 4484719..056776d 100644 --- a/platform.js +++ b/platform.js @@ -1,19 +1,66 @@ -/* +/* * 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() { - + var thisFile = 'platform.js'; var scopeName = 'Platform'; function processFlags(flags) { - this.modules = [flags.debug ? 'platform.debug.js' : 'platform.min.js']; + // truthy value for any of these flags or failure to detect native + // shadowDOM results in polyfill + flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill || + !HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill'; + + var ShadowDOMNative = [ + 'src/patches-shadowdom-native.js' + ]; + + var ShadowDOMPolyfill = [ + '../ShadowDOM/shadowdom.js', + 'src/patches-shadowdom-polyfill.js', + 'src/ShadowCSS.js' + ]; + + var Lib = [ + 'src/lang.js', + 'src/dom.js', + 'src/template.js', + 'src/inspector.js', + ]; + + var MDV = [ + '../mdv/mdv.js', + 'src/patches-mdv.js' + ]; + + var Pointer = [ + '../PointerGestures/pointergestures.js' + ]; + + var WebElements = [ + '../HTMLImports/html-imports.js', + '../CustomElements/custom-elements.js', + 'src/patches-custom-elements.js' + ]; + + // select ShadowDOM impl + var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative; + + // construct active dependency list + this.modules = [].concat( + ShadowDOM, + Lib, + WebElements, + Pointer, + MDV + ); } -// export +// export window[scopeName] = { entryPointName: thisFile, @@ -29,7 +76,7 @@ var basePath = src.slice(0, src.indexOf(thisFile)); if (!window.Loader) { var path = basePath + 'tools/loader/loader.js'; document.write(''); -} +} document.write(''); - + })(); From 248c012f76afd11ac5f95af4a95d0e330d0fc2b6 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 31 Jul 2013 12:15:26 -0700 Subject: [PATCH 11/11] add a ?build flag to load platform.min.js --- platform.js | 101 +++++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/platform.js b/platform.js index 056776d..52e9e16 100644 --- a/platform.js +++ b/platform.js @@ -10,54 +10,59 @@ var thisFile = 'platform.js'; var scopeName = 'Platform'; function processFlags(flags) { - // truthy value for any of these flags or failure to detect native - // shadowDOM results in polyfill - flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill || - !HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill'; - - var ShadowDOMNative = [ - 'src/patches-shadowdom-native.js' - ]; - - var ShadowDOMPolyfill = [ - '../ShadowDOM/shadowdom.js', - 'src/patches-shadowdom-polyfill.js', - 'src/ShadowCSS.js' - ]; - - var Lib = [ - 'src/lang.js', - 'src/dom.js', - 'src/template.js', - 'src/inspector.js', - ]; - - var MDV = [ - '../mdv/mdv.js', - 'src/patches-mdv.js' - ]; - - var Pointer = [ - '../PointerGestures/pointergestures.js' - ]; - - var WebElements = [ - '../HTMLImports/html-imports.js', - '../CustomElements/custom-elements.js', - 'src/patches-custom-elements.js' - ]; - - // select ShadowDOM impl - var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative; - - // construct active dependency list - this.modules = [].concat( - ShadowDOM, - Lib, - WebElements, - Pointer, - MDV - ); + if (flags.build) { + // use the minified build + this.modules = ['platform.min.js']; + } else { + // truthy value for any of these flags or failure to detect native + // shadowDOM results in polyfill + flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill || + !HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill'; + + var ShadowDOMNative = [ + 'src/patches-shadowdom-native.js' + ]; + + var ShadowDOMPolyfill = [ + '../ShadowDOM/shadowdom.js', + 'src/patches-shadowdom-polyfill.js', + 'src/ShadowCSS.js' + ]; + + var Lib = [ + 'src/lang.js', + 'src/dom.js', + 'src/template.js', + 'src/inspector.js', + ]; + + var MDV = [ + '../mdv/mdv.js', + 'src/patches-mdv.js' + ]; + + var Pointer = [ + '../PointerGestures/pointergestures.js' + ]; + + var WebElements = [ + '../HTMLImports/html-imports.js', + '../CustomElements/custom-elements.js', + 'src/patches-custom-elements.js' + ]; + + // select ShadowDOM impl + var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative; + + // construct active dependency list + this.modules = [].concat( + ShadowDOM, + Lib, + WebElements, + Pointer, + MDV + ); + } } // export