Question

I am learning Zombie.js with node.js using sys.debug() statements to track my progress. What is returned by calls like this t = browser.body.querySelector(".navigation"); ? It is hard to tell what is going on without browser developer tools or something like php's var_dump. The API doesn't really explain it.

How do I unpack this?

t = browser.body.querySelector(".navigation");
sys.debug(t); //returns "DEBUG: [ UL.navigation]" I don't know what this means.
Was it helpful?

Solution

.querySelector() is defined as part of a DOM API, specifically the Selectors API, which Zombie.js is using an implementation of.

So, as it does in other browsers, it should return:

[...] the first element that is a descendent of the element on which it is invoked that matches the specified group of selectors.

In this case, based on the UL.navigation in the log, t is an HTMLUListElement. Or:

<ul class="navigation"></ul>

And, in cases where no matching Element can be found, it'll return null.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top