Namespace query string flags with wc-*.

This commit is contained in:
Kevin Schaaf
2015-05-13 12:09:04 -07:00
parent 04e3d7245d
commit 9a089f47d4
6 changed files with 27 additions and 9 deletions

View File

@@ -18,7 +18,10 @@ var flags = {};
if (!flags.noOpts) {
location.search.slice(1).split('&').forEach(function(o) {
o = o.split('=');
o[0] && (flags[o[0]] = o[1] || true);
var m;
if (o[0] && (m = o[0].match(/wc-(.+)/))) {
flags[m[1]] = o[1] || true;
}
});
}

View File

@@ -18,7 +18,10 @@ var flags = {};
if (!flags.noOpts) {
location.search.slice(1).split('&').forEach(function(o) {
o = o.split('=');
o[0] && (flags[o[0]] = o[1] || true);
var m;
if (o[0] && (m = o[0].match(/wc-(.+)/))) {
flags[m[1]] = o[1] || true;
}
});
}

View File

@@ -11,10 +11,10 @@ window.WebComponents = window.WebComponents || {};
// process flags
(function(scope){
// import
var flags = scope.flags || {};
var file = 'webcomponents-lite.js';
var script = document.querySelector('script[src*="' + file + '"]');
@@ -23,7 +23,10 @@ window.WebComponents = window.WebComponents || {};
// from url
location.search.slice(1).split('&').forEach(function(o) {
o = o.split('=');
o[0] && (flags[o[0]] = o[1] || true);
var m;
if (o[0] && (m = o[0].match(/wc-(.+)/))) {
flags[m[1]] = o[1] || true;
}
});
// from script
if (script) {
@@ -48,7 +51,7 @@ window.WebComponents = window.WebComponents || {};
// Determine default settings.
// 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;

View File

@@ -23,7 +23,10 @@ window.WebComponents = window.WebComponents || {};
// from url
location.search.slice(1).split('&').forEach(function(o) {
o = o.split('=');
o[0] && (flags[o[0]] = o[1] || true);
var m;
if (o[0] && (m = o[0].match(/wc-(.+)/))) {
flags[m[1]] = o[1] || true;
}
});
// from script
if (script) {

View File

@@ -23,7 +23,10 @@
// from url
location.search.slice(1).split('&').forEach(function(o) {
o = o.split('=');
o[0] && (flags[o[0]] = o[1] || true);
var m;
if (o[0] && (m = o[0].match(/wc-(.+)/))) {
flags[m[1]] = o[1] || true;
}
});
// from script
if (script) {

View File

@@ -23,7 +23,10 @@
// from url
location.search.slice(1).split('&').forEach(function(o) {
o = o.split('=');
o[0] && (flags[o[0]] = o[1] || true);
var m;
if (o[0] && (m = o[0].match(/wc-(.+)/))) {
flags[m[1]] = o[1] || true;
}
});
// from script
if (script) {