Summary: | Web Inspector needs helper functions that pass a 'this' object to addEventListener and setTimeout | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Timothy Hatcher <timothy> | ||||||
Component: | Web Inspector (Deprecated) | Assignee: | Timothy Hatcher <timothy> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Enhancement | ||||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | All | ||||||||
OS: | All | ||||||||
Attachments: |
|
Description
Timothy Hatcher
2007-11-24 12:55:26 PST
Created attachment 17487 [details]
Patch
Comment on attachment 17487 [details]
Patch
I was thinking about fixing this as well, but in a slightly different way. I was going to add a new function:
Function.bind = function(func, thisObject) {
return function() { func.call(thisObject) }
}
Then you could do things like:
setTimeout(Function.bind(this.updateTitle, this), 0);
What do you think about that solution? I like that it's very general and so can be used in more places.
(In reply to comment #2) > Function.bind = function(func, thisObject) { > return function() { func.call(thisObject) } > } You'd want to pass arguments through, as well. Comment on attachment 17487 [details]
Patch
I am going to redo this based on Adam's comment.
Created attachment 17488 [details]
Revised Patch
Comment on attachment 17488 [details]
Revised Patch
I think "toggleExpanded" would be clearer than just "toggle" for the two places you added that function.
I don't think the order of the <script> elements matters, since none of this code gets executed as it's parsed.
r=me
|