Skip to content

Commit f76297a

Browse files
committed
Properly remove the icon indicator (not from child containers)
1 parent bc74a9d commit f76297a

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

lib/inspector-overlay.js

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ const ToolboxOverlayId = FireQueryToolboxOverlay.prototype.overlayId;
3333

3434
/**
3535
* @overlay This object represents an overlay for the existing
36-
* Inspector panel which is responsible for customization.
36+
* Inspector panel. The overlay is responsible for customization
37+
* of the panel.
3738
*
3839
* Every element that has jQuery.data associated has additional
3940
* icon rendered right next to it. Clicking on the icon opens
4041
* a tooltip displaying the data.
42+
*
43+
* It's also possible to right click on the icon and pick
44+
* 'Show DOM Properties' - it'll show jQuery.data in the
45+
* Variables View (Console's panel side panel). This built-in
46+
* action is usually used for elements.
4147
*/
4248
const InspectorOverlay = Class(
4349
/** @lends InspectorOverlay */
@@ -144,7 +150,7 @@ const InspectorOverlay = Class(
144150
//Trace.sysout("InspectorOverlay.onMarkupViewContainerCreated;");
145151

146152
// Create a little data-icon indicating that the rendered element
147-
// has jQuery.data associated. Clickin on the icon opens a tooltip
153+
// has jQuery.data associated. Clicking on the icon opens a tooltip
148154
// with more details.
149155
let nodeFront = container.node;
150156
if (this.hasJQueryData(nodeFront)) {
@@ -153,19 +159,18 @@ const InspectorOverlay = Class(
153159
},
154160

155161
createDataIcon: function(element) {
156-
Trace.sysout("InspectorOverlay.createDataIcon; ", element);
162+
if (!element.classList.contains("editor")) {
163+
element = element.querySelector(".tag-line .editor");
164+
}
157165

166+
// Bail out if the icon is already created.
158167
let icon = element.querySelector(".fireQueryData");
159168
if (icon) {
160169
return;
161170
}
162171

163-
if (!element.classList.contains("editor")) {
164-
element = element.querySelector(".tag-line .editor");
165-
}
166-
167-
// Create a little icon indicating the the node (displayed in the
168-
// Markup View) has jQuery data associated. Clicking the icon
172+
// Create a little icon indicating that the node (displayed in the
173+
// MarkupView) has jQuery.data associated. Clicking the icon
169174
// displays the data as an expandable tree in a tooltip.
170175
let doc = element.ownerDocument;
171176
icon = doc.createElementNS(XHTML_NS, "span");
@@ -178,14 +183,15 @@ const InspectorOverlay = Class(
178183
},
179184

180185
removeDataIcon: function(element) {
181-
Trace.sysout("InspectorOverlay.removeDataIcon;", element);
186+
if (!element.classList.contains("editor")) {
187+
element = element.querySelector(".tag-line .editor");
188+
}
182189

190+
// Bail out if the icon doesn't exist.
183191
let icon = element.querySelector(".fireQueryData");
184-
if (!icon) {
185-
return;
192+
if (icon) {
193+
icon.remove();
186194
}
187-
188-
icon.remove();
189195
},
190196

191197
onClickTooltip: function(event) {
@@ -256,7 +262,11 @@ const InspectorOverlay = Class(
256262

257263
front.on("data-modified", this.onDataModified);
258264

259-
// Update the markup view
265+
// Update the markup view. It might happen that the backend
266+
// registration is done after the panel is already displayed.
267+
// To improve the first-time experience - the panel is auto
268+
// refreshed so, all jQuery.data indicators are properly
269+
// rendered within the panel.
260270
// xxxHonza: request better API (e.g. this.panel.refresh());
261271
this.panel.onNewRoot();
262272
},
@@ -275,10 +285,11 @@ const InspectorOverlay = Class(
275285
let client = this.toolbox.target.client;
276286
let nodeFront = nodeData.node;
277287

278-
// The container doesn't have to be always there (visible).
288+
// The container doesn't have to be always visible/available.
279289
let container = markupView.getContainer(nodeFront);
280290
if (!container) {
281-
Trace.sysout("InspectorOverlay.onDataModified; No Container", nodeData);
291+
Trace.sysout("InspectorOverlay.onDataModified; no container, " +
292+
"has data: " + hasJQueryData);
282293
return;
283294
}
284295

0 commit comments

Comments
 (0)