This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
/
platform.js
104 lines (80 loc) · 2.44 KB
/
platform.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright 2013 The Polymer Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
(function() {
var thisFile = 'platform.js';
var scopeName = 'Platform';
function processFlags(flags) {
if (flags.build) {
// use the minified build
this.modules = ['platform.min.js'];
} else {
// 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;
}
var ShadowDOMNative = [
'src/patches-shadowdom-native.js'
];
var ShadowDOMPolyfill = [
'../ShadowDOM/shadowdom.js',
'src/patches-shadowdom-polyfill.js',
'src/ShadowCSS.js'
];
// select ShadowDOM impl
var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative;
// construct full dependency list
this.modules = [].concat(
ShadowDOM,
[
'../URL/url.js',
'src/lang.js',
'src/dom.js',
'src/template.js',
'src/inspector.js',
'src/unresolved.js',
'src/module.js',
'src/microtask.js',
'src/url.js',
'../HTMLImports/html-imports.js',
'../CustomElements/custom-elements.js',
'src/patches-custom-elements.js',
'src/loader.js',
'src/styleloader.js',
// TODO(sjmiles): polymer-expressions.js does not load dependencies, but
// the build.json does
'../observe-js/src/observe.js',
'../NodeBind/src/NodeBind.js',
'../TemplateBinding/src/TemplateBinding.js',
'src/patches-mdv.js'
]
);
}
}
// export
window[scopeName] = {
entryPointName: thisFile,
processFlags: processFlags
};
// bootstrap
var script;
if (document.currentScript) {
script = document.currentScript;
} else {
script = document.querySelector('script[src*="' + thisFile + '"]');
}
var src = script.attributes.src.value;
var basePath = src.slice(0, src.indexOf(thisFile));
if (!window.PolymerLoader) {
var path = basePath + '../tools/loader/loader.js';
document.write('<script src="' + path + '"></script>');
}
document.write('<script>PolymerLoader.load("' + scopeName + '")</script>');
})();