0

I am using Firebug in Firefox. I have a giant JavaScript object that holds a lot of other JavaScript objects that in turn also hold objects. I want to find a unique value that could be in any one of these objects. However, Firebug's search field only works on text that's visible inside the DOM panel. When on the list of JavaScript objects, you can click on the plus sign next to it to expand it. However, if an object is not expanded, it seems invisible to the search field.

How do I search for items that are not currently displayed within Firebug's DOM panel?

1 Answer 1

1

Firebug's DOM panel currently (Firebug 2.0.4) doesn't support searching within nested objects. This is a long-standing problem and is reported as issue 1545.

What you can do to circumvent this, is to write your own search function, which returns the result you expect. A simple example for this is the following code:

function searchValue(obj, value) {
  for (var prop in obj) {
    if (typeof obj[prop] === "object") {
      var result = searchValue(obj[prop], value);
      if (result !== '')
        return prop + "." + result;
    }

    if (obj[prop] === value)
      return prop + "." + obj[prop];
  }

  return '';
}

This function does a simple search through the object and returns the path to the property that holds the first occurrence of the value. E.g. calling searchValue(test, "bar") on an object defined as test = {a: "foo", b: {c: {d: "bar"}}} returns "b.c.d". Note that this function doesn't handle recursions, though.

Sign up to request clarification or add additional context in comments.

Comments

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.