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

Commit 7f95f08

Browse files
committed
Merge pull request #28 from azakus/debug-only
Refactor platform loader to be debug by default
2 parents 0209bc9 + 248c012 commit 7f95f08

File tree

2 files changed

+58
-79
lines changed

2 files changed

+58
-79
lines changed

platform.debug.js

-73
This file was deleted.

platform.js

+58-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,71 @@
1-
/*
1+
/*
22
* Copyright 2013 The Polymer Authors. All rights reserved.
33
* Use of this source code is governed by a BSD-style
44
* license that can be found in the LICENSE file.
55
*/
66

77
(function() {
8-
8+
99
var thisFile = 'platform.js';
1010
var scopeName = 'Platform';
1111

1212
function processFlags(flags) {
13-
this.modules = [flags.debug ? 'platform.debug.js' : 'platform.min.js'];
13+
if (flags.build) {
14+
// use the minified build
15+
this.modules = ['platform.min.js'];
16+
} else {
17+
// truthy value for any of these flags or failure to detect native
18+
// shadowDOM results in polyfill
19+
flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill ||
20+
!HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill';
21+
22+
var ShadowDOMNative = [
23+
'src/patches-shadowdom-native.js'
24+
];
25+
26+
var ShadowDOMPolyfill = [
27+
'../ShadowDOM/shadowdom.js',
28+
'src/patches-shadowdom-polyfill.js',
29+
'src/ShadowCSS.js'
30+
];
31+
32+
var Lib = [
33+
'src/lang.js',
34+
'src/dom.js',
35+
'src/template.js',
36+
'src/inspector.js',
37+
];
38+
39+
var MDV = [
40+
'../mdv/mdv.js',
41+
'src/patches-mdv.js'
42+
];
43+
44+
var Pointer = [
45+
'../PointerGestures/pointergestures.js'
46+
];
47+
48+
var WebElements = [
49+
'../HTMLImports/html-imports.js',
50+
'../CustomElements/custom-elements.js',
51+
'src/patches-custom-elements.js'
52+
];
53+
54+
// select ShadowDOM impl
55+
var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative;
56+
57+
// construct active dependency list
58+
this.modules = [].concat(
59+
ShadowDOM,
60+
Lib,
61+
WebElements,
62+
Pointer,
63+
MDV
64+
);
65+
}
1466
}
1567

16-
// export
68+
// export
1769

1870
window[scopeName] = {
1971
entryPointName: thisFile,
@@ -29,7 +81,7 @@ var basePath = src.slice(0, src.indexOf(thisFile));
2981
if (!window.Loader) {
3082
var path = basePath + 'tools/loader/loader.js';
3183
document.write('<script src="' + path + '"></script>');
32-
}
84+
}
3385
document.write('<script>Loader.load("' + scopeName + '")</script>');
34-
86+
3587
})();

0 commit comments

Comments
 (0)