-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(jqLite): silently ignore after()
if element has no parent
#15475
fix(jqLite): silently ignore after()
if element has no parent
#15475
Conversation
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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
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
Docs have been added / updated (for bug fixes / features)Other information:
Fixes #15331
Closes #15367