Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Refactor build boot process
Browse files Browse the repository at this point in the history
Move loader and flag parsing out of "if shadowdom polyfill" branch code

This change makes the "native" build possible
  • Loading branch information
dfreedm committed Apr 16, 2014
1 parent 6e1372e commit d817018
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 60 deletions.
1 change: 1 addition & 0 deletions build-native.json
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",
Expand Down
1 change: 1 addition & 0 deletions build.json
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",
Expand Down
67 changes: 67 additions & 0 deletions build/boot.js
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);
60 changes: 0 additions & 60 deletions build/if-poly.js
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) {

0 comments on commit d817018

Please sign in to comment.