-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(ngMessagesInclude): don't break on empty (or whitespace-only) templates #14726
feat(ngMessagesInclude): don't break on empty (or whitespace-only) templates #14726
Conversation
// we don't want to pollute the DOM anymore by keeping an empty directive element | ||
element.remove(); | ||
}); | ||
if (isString(html) && !html.trim()) { |
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.
trim is doing an isString check, so we should be able to skip it here
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 isString
is needed
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.
Test passes without it ...
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 isString()
is needed in case the request returns some non-string data. This is normally not the case, but can happen (especially in tests).
I didn't test for it explicitly though...
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.
Yes that's why I was confused. If it's not tested it's not really specified. But in that case it's not big deal
LGTM |
1 similar comment
LGTM |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature (or bug fix - depends)
What is the current behavior? (You can also link to an open issue here)
Using
ngMessagesInclude
with an empty template, throws an error. This happens, because when trying to$compile
the template, jqLite thinks we are trying to call it with a selector.See #12941.
What is the new behavior (if this is a feature change)?
Using
ngMessagesInclude
with an empty template (or a template that contains only whitespace), will not throw.Does this PR introduce a breaking change?
Only if you relied on
ngMessagesInclude
throwing an error on empty templates.Please check if the PR fulfills these requirements
Docs have been added / updated (for bug fixes / features)Other information:
Fixes #12941.