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

Commit

Permalink
Merge pull request #3 from Polymer/fix-flags
Browse files Browse the repository at this point in the history
Forward CustomElements and HTMLImports loader flags
  • Loading branch information
Steve Orvell committed Jan 30, 2014
2 parents 731e339 + 9e9e603 commit 1f35990
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
32 changes: 28 additions & 4 deletions build/if-poly.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,45 @@ window.logFlags = window.logFlags || {};
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
// 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
&& 'polyfill';
flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot;
}

// 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 === 'polyfill') {
if (Platform.flags.shadow) {
3 changes: 1 addition & 2 deletions platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ function processFlags(flags) {
if (flags.shadow === 'native') {
flags.shadow = false;
} else {
flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot
&& 'polyfill';
flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot;
}

var ShadowDOMNative = [
Expand Down

0 comments on commit 1f35990

Please sign in to comment.