Closed Bug 637913 Opened 13 years ago Closed 13 years ago

Enhance watchpoints to trigger on property removal

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: sebo, Unassigned)

References

()

Details

(Whiteboard: [firebug-p2])

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Build Identifier: 

Currently watch() adds a watchpoint, which triggers on property addition and change, but not on deletion of that property.

Reproducible: Always

Steps to Reproduce:
1. Execute the following code:
var anObject = {foo: "bar"};
anObject.watch("foo", function handler(id, oldValue, newValue){ alert("hey"); });
delete anObject.foo;
Actual Results:  
anObj.foo gets deleted, but the handler doesn't get triggered.

Expected Results:  
The handler should get triggered with id="foo", oldValue="bar" and newValue=undefined
Probably it would be even better to have a fourth parameter for the handler, which specifies the type of modification (added, changed, removed).

In Firebug this is needed to be able to solve http://code.google.com/p/fbug/issues/detail?id=4162
See also https://bugzilla.mozilla.org/show_bug.cgi?id=579342
Whiteboard: [firebug-p2]
Really do not want to enhance watch, rather leave it alone -- its implementation may change but adding more "dimensionality" seems like a mistake. It is very old and it cuts right through the property access paths.

Jim Blandy is working out a new JS debugger API, exposed to JS, which looks like it can do everything you want and more. I suggest that's the place to ask for new API features.

/be
Yes, 'watch' is something we want to remove, not enhance. The replacement should not be visible to web content, it seems to me.

But the replacement should definitely permit stuff like this; see bug 638044.
Sounds perfect to me. So we can close this issue in favor of bug 638044.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.