forked from googlearchive/platform-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.js
More file actions
91 lines (70 loc) · 2.11 KB
/
platform.js
File metadata and controls
91 lines (70 loc) · 2.11 KB
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
/*
* 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/shadowdom.js'
];
var ShadowDOMPolyfill = [
'../ShadowDOM/shadowdom.js',
'src/shadowdom.js',
'src/ShadowCSS.js'
];
// select ShadowDOM impl
var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative;
// construct full dependency list
this.modules = [].concat(
ShadowDOM,
[
// TODO(sorvell): does this build require url?
'../URL/url.js',
'src/lang.js',
'../HTMLImports/HTMLImports.js',
'../CustomElements/CustomElements.js',
// these scripts are loaded in platform.js due to polyfill timing issues
'src/dom.js',
'src/unresolved.js',
'src/module.js'
]
);
}
}
//CustomElements = {useNative: true};
// 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>');
})();