Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(jqLite): children() should only return elements. #1725

Closed

Conversation

petebacondarwin
Copy link
Contributor

The jQuery implementation of children() only returns child nodes of the given element that are elements themselves. The previous jqLite implementation was returning all nodes except those that are text nodes.

[One should use jQLite.contents() to get all the child nodes]

The testabilityPatch was incorrectly using children() rather than contents() inside cleanup() to iterate down through all the child nodes of the element to clean up.

The "bind should bind to window on hashchange" jqLiteSpec had not defined a childNodes property when it was mocking out the window object, so contents() was blowing up with a stack overflow in that test.

This fixes #1413

The jQuery implementation of children only returns child nodes of the given element that are elements themselves. The previous jqLite implementation was returning all nodes except those that are text nodes. Use jQLite.contents() to get all the child nodes.

The jQuery implementation of contents returns [] if the object has no child nodes.  The previous jqLite implementation was returning undefined, causing a stack overflow in test/testabilityPatch.js when it tried to `cleanup()` a window object.

The testabilityPatch was incorrectly using children() rather than contents() inside cleanup() to iterate down through all the child nodes of the element to clean up.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The children method of JQLite should only return nodes of type Element.
1 participant