-
Notifications
You must be signed in to change notification settings - Fork 0
/
devtools.js
72 lines (62 loc) · 2.13 KB
/
devtools.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
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The function below is executed in the context of the inspected page.
var page_getProperties = function() {
// Make a shallow copy with a null prototype, so that sidebar does not
// expose prototype.
var t = $0;
var e = $0;
while (t && !t.atomControl) {
t = t.parentNode;
}
if (!t)
return { "__type": "None" };
t = t.atomControl;
// this is TSX based new Web Atoms
if (t.app) {
return t;
}
var copy = { "__baseType": t.constructor.__baseType };
copy["__type"] = t.constructor.__typeName;
copy["__baseTypeName"] = t.constructor.__baseType ? t.constructor.__baseType.__typeName : "" ;
for (var k in t) {
if (/^get_/gi.test(k)) {
var f = t[k];
var n = k.substr(4);
if (/^(events|children|owner|visible|cssPrefix)/gi.test(n))
continue;
var v = undefined;
try {
v = f.apply(t);
} catch (err) {
v = "Error executing " + k + ":" + err.toString();
}
if (v !== undefined) {
copy[n] = v;
}
}
}
var bs = t.bindings;
if (bs) {
copy["bindings"] = bs;
for (var i = 0; i < bs.length; i++) {
var b = bs[i];
if (b.element === e) {
copy["__binding"] = b;
break;
}
}
}
return copy;
}
chrome.devtools.panels.elements.createSidebarPane(
"Web Atoms Properties",
function (sidebar) {
function updateElementProperties() {
sidebar.setExpression("(" + page_getProperties.toString() + ")()");
}
updateElementProperties();
chrome.devtools.panels.elements.onSelectionChanged.addListener(
updateElementProperties);
});