Skip to content

Commit bc74a9d

Browse files
committed
Fix data modification event/update
1 parent 692046b commit bc74a9d

File tree

2 files changed

+20
-33
lines changed

2 files changed

+20
-33
lines changed

lib/firequery-actor.js

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ var FireQueryActor = ActorClass(
8484
"data-modified": {
8585
type: "dataModified",
8686
node: Arg(0, "disconnectedNode"),
87-
jQueryData: Arg(1, "nullable:json")
87+
hasJQueryData: Arg(1, "boolean")
8888
}
8989
},
9090

@@ -290,7 +290,7 @@ var FireQueryActor = ActorClass(
290290
patch: Arg(0, "string"),
291291
watcher: Arg(1, "string"),
292292
walker: Arg(2, "string"),
293-
walker: Arg(3, "string")
293+
console: Arg(3, "string")
294294
},
295295
response: {
296296
type: "jquery-patched"
@@ -300,40 +300,31 @@ var FireQueryActor = ActorClass(
300300
onJQueryDetected: makeInfallible(function(event) {
301301
let win = this.parent.window.wrappedJSObject;
302302

303-
Trace.sysout("FireQueryActor.onJQueryDetected; " + win.location, event);
303+
Trace.sysout("FireQueryActor.onJQueryDetected; " +
304+
win.location, this.patch);
304305

305306
win.eval(this.patch);
306307
}),
307308

308309
onDataModified: makeInfallible(function(event) {
309310
let win = this.parent.window.wrappedJSObject;
310311

311-
Trace.sysout("FireQueryActor.onDataModified; " + win.location, event);
312-
312+
// For cases where the DevTool itself are changing jQuery.data()
313+
// Not necessary to cover these cases.
313314
if (ignoreEventParsers()) {
314315
return;
315316
}
316317

317318
let walkerActor = this.conn.getActor(this.walkerActorID);
318-
if (!walkerActor) {
319-
return;
320-
}
321-
322319
let data = walkerActor.attachElement(event.target);
323-
let jQueryData = hasJQueryData(event.target);
320+
let available = !!hasJQueryData(event.target);
324321

325-
Trace.sysout("FireQueryActor.onDataModified;", {
322+
Trace.sysout("FireQueryActor.onDataModified; " + win.location, {
326323
data: data,
327-
jQueryData: jQueryData
324+
hasJQueryData: available
328325
});
329326

330-
try {
331-
// xxxHonza: circular data can't be stringified FIX ME.
332-
let json = jQueryData ? JSON.stringify(jQueryData) : "";
333-
Events.emit(this, "data-modified", data, json);
334-
} catch(err) {
335-
Trace.sysout("FireQueryActor.onDataModified; ERROR " + err, err);
336-
}
327+
Events.emit(this, "data-modified", data, available);
337328
}),
338329

339330
/**

lib/inspector-overlay.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -267,32 +267,28 @@ const InspectorOverlay = Class(
267267

268268
// Backend Events
269269

270-
onDataModified: function(nodeData, jQueryData) {
271-
Trace.sysout("InspectorOverlay.onDataModified;", arguments);
270+
onDataModified: function(nodeData, hasJQueryData) {
271+
Trace.sysout("InspectorOverlay.onDataModified; has data: " +
272+
hasJQueryData);
272273

273274
let markupView = this.panel.markup;
274-
if (!markupView) {
275-
Trace.sysout("InspectorOverlay.onDataModified; ERROR No Markup view",
276-
arguments);
277-
}
278-
279275
let client = this.toolbox.target.client;
280-
281276
let nodeFront = nodeData.node;
277+
278+
// The container doesn't have to be always there (visible).
282279
let container = markupView.getContainer(nodeFront);
283280
if (!container) {
284281
Trace.sysout("InspectorOverlay.onDataModified; No Container", nodeData);
285282
return;
286283
}
287284

288-
let element = container.elt;
289-
290285
// If jQuery data has been removed, remove also the little
291-
// envelop icon from the UI; otherwise make sure it's there.
292-
if (typeof jQueryData == "undefined") {
293-
this.removeDataIcon(element);
294-
} else {
286+
// indicator icon from the UI; otherwise make sure it's there!
287+
let element = container.elt;
288+
if (hasJQueryData) {
295289
this.createDataIcon(element);
290+
} else {
291+
this.removeDataIcon(element);
296292
}
297293
},
298294

0 commit comments

Comments
 (0)