3

I am currently using FireBug to see how hypem delivers it the content to allow its flash player to work (specifically the play button functionality). I have found that the trackList variable is populated with the data but I do not know where it is set.

How can I track when / where this collection is modified? I can add a watch to it but don't know how to trap when it is set.

FYI I am doing this as I want some of this functionality and want to understand how they have done this.

2 Answers 2

2

Here is how you use defineProperty to do it. In my example I'm logging each time window.$ is assigned, along with a call stack. Of course instead of logging you can trigger a debugger; or do something else.

Object.defineProperty(window, "$",
{
  set: function(val) {
    console.log("$ was set to '",val,"' at ",Error().stack);
    this.$internal=val;
  },
  get: function() { return this.$internal; }
});
Sign up to request clarification or add additional context in comments.

Comments

1

Unfortunately, this isn't directly possible.

Instead, you can search through the Javascript and see where the variable is set, then put a normal breakpoint on each line that you find.

3 Comments

I tried this but unfortunately can't seem to find out where it is set!
Try calling defineProperty and putting a breakpoint or console.log call in the property.
Sorry but how do I use defineProperty?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.