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

fix(jqLite): silently ignore after() if element has no parent #15475

Closed

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Dec 8, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix.

What is the current behavior? (You can also link to an open issue here)
The element was always assumed to have a parent and an error was thrown when that was not the case.

What is the new behavior (if this is a feature change)?
jqLite is now consistent with jQuery, which silently ignores a call on elements that do not have a parent.

Does this PR introduce a breaking change?
No. (This change only affects already broken code, that would otherwise throw an error.)

Please check if the PR fulfills these requirements

Other information:
Fixes #15331
Closes #15367

Previously, the element was always assumed to have a parent and an error was
thrown when that was not the case.
This commit makes jqLite consistent with jQuery, which silently ignores a call
on elements that do not have a parent.

Fixes angular#15331
Closes angular#15367

it('should not throw when the element has no parent', function() {
var span = jqLite('<span></span>');
expect(function() { span.after('abc'); }).not.toThrow();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an expect that the span is still the span?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is now failing :o is it because toJqEqual is wrapped in jqlite?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱 It passed locally (on Chrome). IEs seems to have a hard time. I'll take a look.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking DOM Nodes for deep equality isn't an intended usecase apparenty 😃
I changed the expectations.

gkalpak added a commit that referenced this pull request Dec 8, 2016
Previously, the element was always assumed to have a parent and an error was
thrown when that was not the case.
This commit makes jqLite consistent with jQuery, which silently ignores a call
on elements that do not have a parent.

Fixes #15331
Closes #15367

Closes #15475
@gkalpak gkalpak closed this in a9e9146 Dec 8, 2016
@gkalpak gkalpak deleted the fix-jqLite-after-ignore-if-no-parent branch December 8, 2016 16:13
gkalpak added a commit that referenced this pull request Dec 9, 2016
Previously, the element was always assumed to have a parent and an error was
thrown when that was not the case.
This commit makes jqLite consistent with jQuery, which silently ignores a call
on elements that do not have a parent.

Fixes #15331
Closes #15367

Closes #15475
ellimist pushed a commit to ellimist/angular.js that referenced this pull request Mar 15, 2017
Previously, the element was always assumed to have a parent and an error was
thrown when that was not the case.
This commit makes jqLite consistent with jQuery, which silently ignores a call
on elements that do not have a parent.

Fixes angular#15331
Closes angular#15367

Closes angular#15475
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.

parent is null in JQLite code
3 participants