polymer-rails 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/polymer/polymer-micro.html +528 -21
- data/app/assets/javascripts/polymer/polymer-mini.html +1304 -27
- data/app/assets/javascripts/polymer/polymer.html +3771 -51
- data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +44 -14
- data/app/assets/javascripts/webcomponentsjs/webcomponents.js +7106 -0
- data/lib/polymer-rails/version.rb +1 -1
- metadata +4 -64
- data/app/assets/javascripts/polymer/src/lib/annotations/annotations.html +0 -262
- data/app/assets/javascripts/polymer/src/lib/annotations/demo/app-chrome.html +0 -60
- data/app/assets/javascripts/polymer/src/lib/array-observe.html +0 -118
- data/app/assets/javascripts/polymer/src/lib/array-splice.html +0 -262
- data/app/assets/javascripts/polymer/src/lib/async.html +0 -68
- data/app/assets/javascripts/polymer/src/lib/base.html +0 -117
- data/app/assets/javascripts/polymer/src/lib/bind/accessors.html +0 -223
- data/app/assets/javascripts/polymer/src/lib/bind/demo/app-chrome.html +0 -28
- data/app/assets/javascripts/polymer/src/lib/bind/demo/app.html +0 -29
- data/app/assets/javascripts/polymer/src/lib/bind/demo/src/annotations-bind-demo.html +0 -76
- data/app/assets/javascripts/polymer/src/lib/bind/demo/src/bind-demo.html +0 -83
- data/app/assets/javascripts/polymer/src/lib/bind/effects.html +0 -80
- data/app/assets/javascripts/polymer/src/lib/case-map.html +0 -46
- data/app/assets/javascripts/polymer/src/lib/collection.html +0 -179
- data/app/assets/javascripts/polymer/src/lib/css-parse.html +0 -131
- data/app/assets/javascripts/polymer/src/lib/debounce.html +0 -69
- data/app/assets/javascripts/polymer/src/lib/dom-api.html +0 -467
- data/app/assets/javascripts/polymer/src/lib/dom-module.html +0 -68
- data/app/assets/javascripts/polymer/src/lib/event-api.html +0 -92
- data/app/assets/javascripts/polymer/src/lib/expr/focus.html +0 -22
- data/app/assets/javascripts/polymer/src/lib/expr/gestures.html +0 -1
- data/app/assets/javascripts/polymer/src/lib/expr/log.html +0 -21
- data/app/assets/javascripts/polymer/src/lib/expr/sinspect.html +0 -235
- data/app/assets/javascripts/polymer/src/lib/expr/style-auditor.html +0 -123
- data/app/assets/javascripts/polymer/src/lib/expr/style-protector.html +0 -52
- data/app/assets/javascripts/polymer/src/lib/gestures.html +0 -284
- data/app/assets/javascripts/polymer/src/lib/lang.html +0 -21
- data/app/assets/javascripts/polymer/src/lib/module.html +0 -56
- data/app/assets/javascripts/polymer/src/lib/polymer-bootstrap.html +0 -78
- data/app/assets/javascripts/polymer/src/lib/resolve-url.html +0 -82
- data/app/assets/javascripts/polymer/src/lib/settings.html +0 -52
- data/app/assets/javascripts/polymer/src/lib/style-defaults.html +0 -32
- data/app/assets/javascripts/polymer/src/lib/style-transformer.html +0 -185
- data/app/assets/javascripts/polymer/src/lib/style-util.html +0 -77
- data/app/assets/javascripts/polymer/src/lib/template/templatizer.html +0 -132
- data/app/assets/javascripts/polymer/src/lib/template/x-array-selector.html +0 -178
- data/app/assets/javascripts/polymer/src/lib/template/x-autobind.html +0 -80
- data/app/assets/javascripts/polymer/src/lib/template/x-if.html +0 -115
- data/app/assets/javascripts/polymer/src/lib/template/x-repeat.html +0 -510
- data/app/assets/javascripts/polymer/src/lib/template/x-template.html +0 -39
- data/app/assets/javascripts/polymer/src/lib/x-style.html +0 -115
- data/app/assets/javascripts/polymer/src/micro/attributes.html +0 -180
- data/app/assets/javascripts/polymer/src/micro/constructor.html +0 -74
- data/app/assets/javascripts/polymer/src/micro/extends.html +0 -79
- data/app/assets/javascripts/polymer/src/micro/mixins.html +0 -40
- data/app/assets/javascripts/polymer/src/micro/properties.html +0 -96
- data/app/assets/javascripts/polymer/src/micro/tag.html +0 -28
- data/app/assets/javascripts/polymer/src/mini/ready.html +0 -180
- data/app/assets/javascripts/polymer/src/mini/shadow.html +0 -41
- data/app/assets/javascripts/polymer/src/mini/shady.html +0 -365
- data/app/assets/javascripts/polymer/src/mini/template.html +0 -56
- data/app/assets/javascripts/polymer/src/polymer-lib.html +0 -15
- data/app/assets/javascripts/polymer/src/standard/annotations.html +0 -198
- data/app/assets/javascripts/polymer/src/standard/configure.html +0 -160
- data/app/assets/javascripts/polymer/src/standard/effects.html +0 -215
- data/app/assets/javascripts/polymer/src/standard/events.html +0 -127
- data/app/assets/javascripts/polymer/src/standard/notify-path.html +0 -260
- data/app/assets/javascripts/polymer/src/standard/resolveUrl.html +0 -27
- data/app/assets/javascripts/polymer/src/standard/styling.html +0 -157
- data/app/assets/javascripts/polymer/src/standard/utils.html +0 -158
- data/app/assets/javascripts/polymer/src/standard/x-styling.html +0 -300
@@ -1,68 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
|
3
|
-
(function() {
|
4
|
-
|
5
|
-
var modules = {};
|
6
|
-
|
7
|
-
var DomModule = function() {
|
8
|
-
return document.createElement('dom-module');
|
9
|
-
};
|
10
|
-
|
11
|
-
DomModule.prototype = Object.create(HTMLElement.prototype);
|
12
|
-
|
13
|
-
DomModule.prototype.constructor = DomModule;
|
14
|
-
|
15
|
-
DomModule.prototype.createdCallback = function() {
|
16
|
-
var id = this.id || this.getAttribute('name') || this.getAttribute('is');
|
17
|
-
if (id) {
|
18
|
-
this.id = id;
|
19
|
-
modules[id] = this;
|
20
|
-
}
|
21
|
-
};
|
22
|
-
|
23
|
-
DomModule.prototype.import = function(id, slctr) {
|
24
|
-
var m = modules[id];
|
25
|
-
if (!m) {
|
26
|
-
// If polyfilling, a script can run before a dom-module element
|
27
|
-
// is upgraded. We force the containing document to upgrade
|
28
|
-
// and try again to workaround this polyfill limitation.
|
29
|
-
forceDocumentUpgrade();
|
30
|
-
m = modules[id];
|
31
|
-
}
|
32
|
-
if (m && slctr) {
|
33
|
-
m = m.querySelector(slctr);
|
34
|
-
}
|
35
|
-
return m;
|
36
|
-
};
|
37
|
-
|
38
|
-
// NOTE: HTMLImports polyfill does not
|
39
|
-
// block scripts on upgrading elements. However, we want to ensure that
|
40
|
-
// any dom-module in the tree is available prior to a subsequent script
|
41
|
-
// processing.
|
42
|
-
// Therefore, we force any dom-modules in the tree to upgrade when dom-module
|
43
|
-
// is registered by temporarily setting CE polyfill to crawl the entire
|
44
|
-
// imports tree. (Note: this should only upgrade any imports that have been
|
45
|
-
// loaded by this point. In addition the HTMLImports polyfill should be
|
46
|
-
// changed to upgrade elements prior to running any scripts.)
|
47
|
-
var cePolyfill = window.CustomElements && !CustomElements.useNative;
|
48
|
-
if (cePolyfill) {
|
49
|
-
var ready = CustomElements.ready;
|
50
|
-
CustomElements.ready = true;
|
51
|
-
}
|
52
|
-
document.registerElement('dom-module', DomModule);
|
53
|
-
if (cePolyfill) {
|
54
|
-
CustomElements.ready = ready;
|
55
|
-
}
|
56
|
-
|
57
|
-
function forceDocumentUpgrade() {
|
58
|
-
if (cePolyfill) {
|
59
|
-
var script = document._currentScript || document.currentScript;
|
60
|
-
if (script) {
|
61
|
-
CustomElements.upgradeAll(script.ownerDocument);
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
})();
|
67
|
-
|
68
|
-
</script>
|
@@ -1,92 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@license
|
3
|
-
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
-
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
-
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
-
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
-
Code distributed by Google as part of the polymer project is also
|
8
|
-
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
-
-->
|
10
|
-
<link rel="import" href="settings.html">
|
11
|
-
<script>
|
12
|
-
|
13
|
-
Polymer.EventApi = (function() {
|
14
|
-
|
15
|
-
var Settings = Polymer.Settings;
|
16
|
-
|
17
|
-
var EventApi = function(event) {
|
18
|
-
this.event = event;
|
19
|
-
};
|
20
|
-
|
21
|
-
if (Settings.useShadow) {
|
22
|
-
|
23
|
-
EventApi.prototype = {
|
24
|
-
|
25
|
-
get rootTarget() {
|
26
|
-
return this.event.path[0];
|
27
|
-
},
|
28
|
-
|
29
|
-
get localTarget() {
|
30
|
-
return this.event.target;
|
31
|
-
},
|
32
|
-
|
33
|
-
get path() {
|
34
|
-
return this.event.path;
|
35
|
-
}
|
36
|
-
|
37
|
-
};
|
38
|
-
|
39
|
-
} else {
|
40
|
-
|
41
|
-
EventApi.prototype = {
|
42
|
-
|
43
|
-
get rootTarget() {
|
44
|
-
return this.event.target;
|
45
|
-
},
|
46
|
-
|
47
|
-
get localTarget() {
|
48
|
-
var current = this.event.currentTarget;
|
49
|
-
var currentRoot = current && Polymer.dom(current)._getOwnerShadyRoot();
|
50
|
-
var p$ = this.path;
|
51
|
-
for (var i=0; i < p$.length; i++) {
|
52
|
-
if (Polymer.dom(p$[i])._getOwnerShadyRoot() === currentRoot) {
|
53
|
-
return p$[i];
|
54
|
-
}
|
55
|
-
}
|
56
|
-
},
|
57
|
-
|
58
|
-
// TODO(sorvell): simulate event.path. This probably incorrect for
|
59
|
-
// non-bubbling events.
|
60
|
-
get path() {
|
61
|
-
if (!this.event._path) {
|
62
|
-
var path = [];
|
63
|
-
var o = this.rootTarget;
|
64
|
-
while (o) {
|
65
|
-
path.push(o);
|
66
|
-
o = Polymer.dom(o).parentNode || o.host;
|
67
|
-
}
|
68
|
-
// event path includes window in most recent native implementations
|
69
|
-
path.push(window);
|
70
|
-
this.event._path = path;
|
71
|
-
}
|
72
|
-
return this.event._path;
|
73
|
-
}
|
74
|
-
|
75
|
-
};
|
76
|
-
|
77
|
-
}
|
78
|
-
|
79
|
-
var factory = function(event) {
|
80
|
-
if (!event.__eventApi) {
|
81
|
-
event.__eventApi = new EventApi(event);
|
82
|
-
}
|
83
|
-
return event.__eventApi;
|
84
|
-
};
|
85
|
-
|
86
|
-
return {
|
87
|
-
factory: factory
|
88
|
-
};
|
89
|
-
|
90
|
-
})();
|
91
|
-
|
92
|
-
</script>
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@license
|
3
|
-
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
-
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
-
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
-
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
-
Code distributed by Google as part of the polymer project is also
|
8
|
-
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
-
-->
|
10
|
-
<script>
|
11
|
-
|
12
|
-
Base.addFeature({
|
13
|
-
|
14
|
-
init: function() {
|
15
|
-
if (this.focusable) {
|
16
|
-
this.tabIndex = 0;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
});
|
21
|
-
|
22
|
-
</script>
|
@@ -1 +0,0 @@
|
|
1
|
-
<script src="../../polymer-gestures/polymer-gestures.js"></script>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@license
|
3
|
-
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
-
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
-
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
-
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
-
Code distributed by Google as part of the polymer project is also
|
8
|
-
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
-
-->
|
10
|
-
<script>
|
11
|
-
|
12
|
-
Base.addFeature({
|
13
|
-
log: function() {
|
14
|
-
var args = Array.prototype.slice.call(arguments, 0);
|
15
|
-
args[0] = '[%s]: ' + args[0];
|
16
|
-
args.splice(1, 0, this.localName);
|
17
|
-
console.log.apply(console, args);
|
18
|
-
}
|
19
|
-
});
|
20
|
-
|
21
|
-
</script>
|
@@ -1,235 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@license
|
3
|
-
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
-
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
-
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
-
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
-
Code distributed by Google as part of the polymer project is also
|
8
|
-
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
-
-->
|
10
|
-
<script>
|
11
|
-
|
12
|
-
(function(scope) {
|
13
|
-
|
14
|
-
scope = scope || (window.Inspector = {});
|
15
|
-
|
16
|
-
var inspector;
|
17
|
-
|
18
|
-
window.sinspect = function(inNode, inProxy) {
|
19
|
-
if (!inspector) {
|
20
|
-
inspector = window.open('', 'ShadowDOM Inspector', null, true);
|
21
|
-
inspector.document.write(inspectorHTML);
|
22
|
-
//inspector.document.close();
|
23
|
-
inspector.api = {
|
24
|
-
shadowize: shadowize
|
25
|
-
};
|
26
|
-
}
|
27
|
-
inspect(inNode || wrap(document.body), inProxy);
|
28
|
-
};
|
29
|
-
|
30
|
-
var inspectorHTML = [
|
31
|
-
'<!DOCTYPE html>',
|
32
|
-
'<html>',
|
33
|
-
' <head>',
|
34
|
-
' <title>ShadowDOM Inspector</title>',
|
35
|
-
' <style>',
|
36
|
-
' body {',
|
37
|
-
' }',
|
38
|
-
' pre {',
|
39
|
-
' font: 9pt "Courier New", monospace;',
|
40
|
-
' line-height: 1.5em;',
|
41
|
-
' }',
|
42
|
-
' tag {',
|
43
|
-
' color: purple;',
|
44
|
-
' }',
|
45
|
-
' ul {',
|
46
|
-
' margin: 0;',
|
47
|
-
' padding: 0;',
|
48
|
-
' list-style: none;',
|
49
|
-
' }',
|
50
|
-
' li {',
|
51
|
-
' display: inline-block;',
|
52
|
-
' background-color: #f1f1f1;',
|
53
|
-
' padding: 4px 6px;',
|
54
|
-
' border-radius: 4px;',
|
55
|
-
' margin-right: 4px;',
|
56
|
-
' }',
|
57
|
-
' button {',
|
58
|
-
' display: inline-block;',
|
59
|
-
' color: purple;',
|
60
|
-
' font-weight: bold;',
|
61
|
-
' background: none;',
|
62
|
-
' border: none;',
|
63
|
-
' outline: none;',
|
64
|
-
' padding: 0;',
|
65
|
-
' margin: 0;',
|
66
|
-
' }',
|
67
|
-
' </style>',
|
68
|
-
' </head>',
|
69
|
-
' <body>',
|
70
|
-
' <ul id="crumbs">',
|
71
|
-
' </ul>',
|
72
|
-
' <div id="tree"></div>',
|
73
|
-
' </body>',
|
74
|
-
'</html>'
|
75
|
-
].join('\n');
|
76
|
-
|
77
|
-
var crumbs = [];
|
78
|
-
|
79
|
-
var displayCrumbs = function() {
|
80
|
-
// alias our document
|
81
|
-
var d = inspector.document;
|
82
|
-
// get crumbbar
|
83
|
-
var cb = d.querySelector('#crumbs');
|
84
|
-
// clear crumbs
|
85
|
-
cb.textContent = '';
|
86
|
-
// build new crumbs
|
87
|
-
for (var i=0, c; c=crumbs[i]; i++) {
|
88
|
-
var a = d.createElement('a');
|
89
|
-
a.href = '#';
|
90
|
-
a.textContent = c.localName;
|
91
|
-
a.idx = i;
|
92
|
-
a.onclick = function(event) {
|
93
|
-
var c;
|
94
|
-
while (crumbs.length > this.idx) {
|
95
|
-
c = crumbs.pop();
|
96
|
-
}
|
97
|
-
inspect(c.shadow || c, c);
|
98
|
-
event.preventDefault();
|
99
|
-
};
|
100
|
-
cb.appendChild(d.createElement('li')).appendChild(a);
|
101
|
-
}
|
102
|
-
};
|
103
|
-
|
104
|
-
var inspect = function(inNode, inProxy) {
|
105
|
-
// alias our document
|
106
|
-
var d = inspector.document;
|
107
|
-
// reset list of drillable nodes
|
108
|
-
drillable = [];
|
109
|
-
// memoize our crumb proxy
|
110
|
-
var proxy = inProxy || inNode;
|
111
|
-
crumbs.push(proxy);
|
112
|
-
// update crumbs
|
113
|
-
displayCrumbs();
|
114
|
-
// reflect local tree
|
115
|
-
d.body.querySelector('#tree').innerHTML =
|
116
|
-
'<pre>' + output(inNode, getLocalNodes(inNode)) + '</pre>';
|
117
|
-
};
|
118
|
-
|
119
|
-
var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);
|
120
|
-
|
121
|
-
var blacklisted = {STYLE:1, SCRIPT:1, "#comment": 1, TEMPLATE: 1};
|
122
|
-
var blacklist = function(inNode) {
|
123
|
-
return blacklisted[inNode.nodeName];
|
124
|
-
};
|
125
|
-
|
126
|
-
var output = function(inNode, inChildNodes, inIndent) {
|
127
|
-
if (blacklist(inNode)) {
|
128
|
-
return '';
|
129
|
-
}
|
130
|
-
var indent = inIndent || '';
|
131
|
-
if (inNode.localName || inNode.domRoot) {
|
132
|
-
var name = inNode.localName || ROOT_NAME;
|
133
|
-
//inChildNodes = ShadowDOM.localNodes(inNode);
|
134
|
-
var info = indent + describe(inNode);
|
135
|
-
// if only textNodes
|
136
|
-
// TODO(sjmiles): make correct for ShadowDOM
|
137
|
-
/*if (!inNode.children.length && inNode.localName !== 'content' && inNode.localName !== 'shadow') {
|
138
|
-
info += catTextContent(inChildNodes);
|
139
|
-
} else*/ {
|
140
|
-
// TODO(sjmiles): native <shadow> has no reference to its projection
|
141
|
-
if (name == 'content' /*|| name == 'shadow'*/) {
|
142
|
-
inChildNodes = getDistributedNodes(inNode);
|
143
|
-
}
|
144
|
-
info += '<br/>';
|
145
|
-
var ind = indent + ' ';
|
146
|
-
//console.group('output ' + inNode.localName);
|
147
|
-
//console.log(inChildNodes);
|
148
|
-
forEach(inChildNodes, function(n) {
|
149
|
-
info += output(n, getLightNodes(n), ind);
|
150
|
-
});
|
151
|
-
//console.groupEnd('output ' + inNode.localName);
|
152
|
-
info += indent;
|
153
|
-
}
|
154
|
-
if (!({br:1}[name])) {
|
155
|
-
info += '<tag></' + name + '></tag>';
|
156
|
-
info += '<br/>';
|
157
|
-
}
|
158
|
-
} else {
|
159
|
-
var text = inNode.textContent.trim();
|
160
|
-
info = text ? indent + '"' + text + '"' + '<br/>' : '';
|
161
|
-
}
|
162
|
-
return info;
|
163
|
-
};
|
164
|
-
|
165
|
-
var catTextContent = function(inChildNodes) {
|
166
|
-
var info = '';
|
167
|
-
forEach(inChildNodes, function(n) {
|
168
|
-
info += n.textContent.trim();
|
169
|
-
});
|
170
|
-
return info;
|
171
|
-
};
|
172
|
-
|
173
|
-
var drillable = [];
|
174
|
-
|
175
|
-
var describe = function(inNode) {
|
176
|
-
var tag = '<tag>' + '<';
|
177
|
-
var name = inNode.localName || ROOT_NAME;
|
178
|
-
if (hasRoot(inNode)) {
|
179
|
-
tag += '<button idx="' + drillable.length +
|
180
|
-
'" onclick="api.shadowize.call(this)">' + name + '</button>';
|
181
|
-
drillable.push(inNode);
|
182
|
-
} else {
|
183
|
-
tag += name || ROOT_NAME;
|
184
|
-
}
|
185
|
-
if (inNode.attributes) {
|
186
|
-
forEach(inNode.attributes, function(a) {
|
187
|
-
tag += ' ' + a.name + (a.value ? '="' + a.value + '"' : '');
|
188
|
-
});
|
189
|
-
}
|
190
|
-
tag += '>'+ '</tag>';
|
191
|
-
return tag;
|
192
|
-
};
|
193
|
-
|
194
|
-
// remote api
|
195
|
-
|
196
|
-
shadowize = function() {
|
197
|
-
var idx = Number(this.attributes.idx.value);
|
198
|
-
//alert(idx);
|
199
|
-
var node = drillable[idx];
|
200
|
-
if (node) {
|
201
|
-
inspect(node, node)
|
202
|
-
} else {
|
203
|
-
console.log("bad shadowize node");
|
204
|
-
console.dir(this);
|
205
|
-
}
|
206
|
-
};
|
207
|
-
|
208
|
-
// util
|
209
|
-
|
210
|
-
var ROOT_NAME = 'local-root';
|
211
|
-
|
212
|
-
function hasRoot(node) {
|
213
|
-
return (node.shadyRoot || node.shadowRoot);
|
214
|
-
}
|
215
|
-
|
216
|
-
function getLocalNodes(n) {
|
217
|
-
return Polymer.dom.childNodes(n.root);
|
218
|
-
}
|
219
|
-
|
220
|
-
function getLightNodes(n) {
|
221
|
-
return Polymer.dom.childNodes(n);
|
222
|
-
}
|
223
|
-
|
224
|
-
function getDistributedNodes(node) {
|
225
|
-
Polymer.dom.distributedNodes(node);
|
226
|
-
}
|
227
|
-
|
228
|
-
|
229
|
-
// export
|
230
|
-
|
231
|
-
scope.output = output;
|
232
|
-
|
233
|
-
})(window.Inspector);
|
234
|
-
|
235
|
-
</script>
|
@@ -1,123 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
addEventListener('WebComponentsReady', function() {
|
3
|
-
|
4
|
-
// given a list of elements, produce a report of rules that
|
5
|
-
// match those elements.
|
6
|
-
var auditor = {
|
7
|
-
|
8
|
-
matchesForDocument: function(elements) {
|
9
|
-
var info = [];
|
10
|
-
this.documentSheets.forEach(function(sheet) {
|
11
|
-
var list = this.matchesForSheet(sheet, elements);
|
12
|
-
if (list.length) {
|
13
|
-
info.push({sheet: sheet, rules: list});
|
14
|
-
}
|
15
|
-
}, this);
|
16
|
-
return info;
|
17
|
-
},
|
18
|
-
|
19
|
-
// TODO(sorvell): support stylesheets inside HTMLImports
|
20
|
-
documentSheets: Array.prototype.filter.call(document.styleSheets,
|
21
|
-
function(sheet) {
|
22
|
-
return !sheet.ownerNode.hasAttribute('scope');
|
23
|
-
}
|
24
|
-
),
|
25
|
-
|
26
|
-
matchesForSheet: function(sheet, elements) {
|
27
|
-
var info = [];
|
28
|
-
Array.prototype.forEach.call(sheet.cssRules, function(rule) {
|
29
|
-
var list = this.matchesForRule(rule, elements);
|
30
|
-
if (list.length) {
|
31
|
-
info.push({selector: rule.selectorText, elements: list});
|
32
|
-
}
|
33
|
-
}, this);
|
34
|
-
return info;
|
35
|
-
},
|
36
|
-
|
37
|
-
matchesForRule: function(rule, list) {
|
38
|
-
var info = [];
|
39
|
-
list.forEach(function(i) {
|
40
|
-
var elements = i.elements.filter(function(e) {
|
41
|
-
return matchesSelector.call(e, rule.selectorText);
|
42
|
-
});
|
43
|
-
if (elements.length) {
|
44
|
-
info.push({host: i.host, elements: elements});
|
45
|
-
}
|
46
|
-
});
|
47
|
-
return info;
|
48
|
-
}
|
49
|
-
|
50
|
-
};
|
51
|
-
|
52
|
-
var p = Element.prototype;
|
53
|
-
var matchesSelector = p.matches || p.matchesSelector ||
|
54
|
-
p.mozMatchesSelector || p.msMatchesSelector ||
|
55
|
-
p.oMatchesSelector || p.webkitMatchesSelector;
|
56
|
-
|
57
|
-
|
58
|
-
// crawl the document and return a list of custom elements with shadyRoots
|
59
|
-
// and their scoped contents
|
60
|
-
var crawler = {
|
61
|
-
// list of elements: array of {host, elements}
|
62
|
-
list: function() {
|
63
|
-
var list = [];
|
64
|
-
var elements = this.elementsWithShadyRoot();
|
65
|
-
elements.forEach(function(e) {
|
66
|
-
list.push({host: e, elements: this.elementsInsideShadyRoot(e)});
|
67
|
-
}, this);
|
68
|
-
return list;
|
69
|
-
},
|
70
|
-
|
71
|
-
elementsWithShadyRoot: function() {
|
72
|
-
var e$ = Polymer.dom(document).querySelectorAll('*');
|
73
|
-
return this.filterElementsWithRoots(e$);
|
74
|
-
},
|
75
|
-
|
76
|
-
elementsInsideShadyRoot: function(e) {
|
77
|
-
var e$ = Polymer.dom(e.root || e).querySelectorAll('*');
|
78
|
-
var roots = this.filterElementsWithRoots(e$);
|
79
|
-
roots.forEach(function(e) {
|
80
|
-
e$ = e$.concat(this.elementsInsideShadyRoot(e));
|
81
|
-
}, this);
|
82
|
-
return e$;
|
83
|
-
},
|
84
|
-
|
85
|
-
filterElementsWithRoots: function(elements) {
|
86
|
-
return elements.filter(function(e) {
|
87
|
-
return e.shadyRoot;
|
88
|
-
});
|
89
|
-
}
|
90
|
-
|
91
|
-
};
|
92
|
-
|
93
|
-
// dump an auditor report
|
94
|
-
var logger = {
|
95
|
-
|
96
|
-
dump: function(log) {
|
97
|
-
log.forEach(function(l) {
|
98
|
-
console.group(l.sheet.ownerNode);
|
99
|
-
this.dumpRules(l.rules);
|
100
|
-
console.groupEnd(l.sheet.ownerNode);
|
101
|
-
}, this);
|
102
|
-
},
|
103
|
-
|
104
|
-
dumpRules: function(rules) {
|
105
|
-
rules.forEach(function(i) {
|
106
|
-
console.group(i.selector);
|
107
|
-
console.log(i.elements);
|
108
|
-
console.groupEnd(i.selector);
|
109
|
-
});
|
110
|
-
}
|
111
|
-
|
112
|
-
};
|
113
|
-
|
114
|
-
// pruduces a style audit and reports results on the console.
|
115
|
-
function audit() {
|
116
|
-
var report = auditor.matchesForDocument(crawler.list());
|
117
|
-
logger.dump(report);
|
118
|
-
}
|
119
|
-
|
120
|
-
audit();
|
121
|
-
|
122
|
-
});
|
123
|
-
</script>
|