This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move loader and flag parsing out of "if shadowdom polyfill" branch code This change makes the "native" build possible
- Loading branch information
Showing
4 changed files
with
69 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[ | ||
"build/boot.js", | ||
"src/patches-shadowdom-native.js", | ||
|
||
"src/lang.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[ | ||
"build/boot.js", | ||
"../WeakMap/weakmap.js", | ||
"../observe-js/src/observe.js", | ||
"build/if-poly.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | ||
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | ||
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | ||
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt | ||
* Code distributed by Google as part of the polymer project is also | ||
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt | ||
*/ | ||
|
||
window.Platform = window.Platform || {}; | ||
// prepopulate window.logFlags if necessary | ||
window.logFlags = window.logFlags || {}; | ||
// process flags | ||
(function(scope){ | ||
// import | ||
var flags = scope.flags || {}; | ||
// populate flags from location | ||
location.search.slice(1).split('&').forEach(function(o) { | ||
o = o.split('='); | ||
o[0] && (flags[o[0]] = o[1] || true); | ||
}); | ||
var entryPoint = document.currentScript || | ||
document.querySelector('script[src*="platform.js"]'); | ||
if (entryPoint) { | ||
var a = entryPoint.attributes; | ||
for (var i = 0, n; i < a.length; i++) { | ||
n = a[i]; | ||
if (n.name !== 'src') { | ||
flags[n.name] = n.value || true; | ||
} | ||
} | ||
} | ||
if (flags.log) { | ||
flags.log.split(',').forEach(function(f) { | ||
window.logFlags[f] = true; | ||
}); | ||
} | ||
// If any of these flags match 'native', then force native ShadowDOM; any | ||
// other truthy value, or failure to detect native | ||
// ShadowDOM, results in polyfill | ||
flags.shadow = flags.shadow || flags.shadowdom || flags.polyfill; | ||
if (flags.shadow === 'native') { | ||
flags.shadow = false; | ||
} else { | ||
flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot; | ||
} | ||
|
||
if (flags.shadow && document.querySelectorAll('script').length > 1) { | ||
console.warn('platform.js is not the first script on the page. ' + | ||
'See http://www.polymer-project.org/docs/start/platform.html#setup ' + | ||
'for details.'); | ||
} | ||
|
||
// CustomElements polyfill flag | ||
if (flags.register) { | ||
window.CustomElements = window.CustomElements || {flags: {}}; | ||
window.CustomElements.flags.register = flags.register; | ||
} | ||
|
||
if (flags.imports) { | ||
window.HTMLImports = window.HTMLImports || {flags: {}}; | ||
window.HTMLImports.flags.imports = flags.imports; | ||
} | ||
|
||
// export | ||
scope.flags = flags; | ||
})(Platform); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,2 @@ | ||
// prepoulate window.Platform.flags for default controls | ||
window.Platform = window.Platform || {}; | ||
// prepopulate window.logFlags if necessary | ||
window.logFlags = window.logFlags || {}; | ||
// process flags | ||
(function(scope){ | ||
// import | ||
var flags = scope.flags || {}; | ||
// populate flags from location | ||
location.search.slice(1).split('&').forEach(function(o) { | ||
o = o.split('='); | ||
o[0] && (flags[o[0]] = o[1] || true); | ||
}); | ||
var entryPoint = document.currentScript || | ||
document.querySelector('script[src*="platform.js"]'); | ||
if (entryPoint) { | ||
var a = entryPoint.attributes; | ||
for (var i = 0, n; i < a.length; i++) { | ||
n = a[i]; | ||
if (n.name !== 'src') { | ||
flags[n.name] = n.value || true; | ||
} | ||
} | ||
} | ||
if (flags.log) { | ||
flags.log.split(',').forEach(function(f) { | ||
window.logFlags[f] = true; | ||
}); | ||
} | ||
// If any of these flags match 'native', then force native ShadowDOM; any | ||
// other truthy value, or failure to detect native | ||
// ShadowDOM, results in polyfill | ||
flags.shadow = flags.shadow || flags.shadowdom || flags.polyfill; | ||
if (flags.shadow === 'native') { | ||
flags.shadow = false; | ||
} else { | ||
flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot; | ||
} | ||
|
||
if (flags.shadow && document.querySelectorAll('script').length > 1) { | ||
console.warn('platform.js is not the first script on the page. ' + | ||
'See http://www.polymer-project.org/docs/start/platform.html#setup ' + | ||
'for details.'); | ||
} | ||
|
||
// CustomElements polyfill flag | ||
if (flags.register) { | ||
window.CustomElements = window.CustomElements || {flags: {}}; | ||
window.CustomElements.flags.register = flags.register; | ||
} | ||
|
||
if (flags.imports) { | ||
window.HTMLImports = window.HTMLImports || {flags: {}}; | ||
window.HTMLImports.flags.imports = flags.imports; | ||
} | ||
|
||
// export | ||
scope.flags = flags; | ||
})(Platform); | ||
|
||
// select ShadowDOM impl | ||
if (Platform.flags.shadow) { |