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

feat(ngMessagesInclude): don't break on empty (or whitespace-only) templates #14726

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Jun 7, 2016

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

Other information:
Fixes #12941.

// we don't want to pollute the DOM anymore by keeping an empty directive element
element.remove();
});
if (isString(html) && !html.trim()) {
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The isString is needed

Copy link
Contributor

Choose a reason for hiding this comment

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

Test passes without it ...

Copy link
Member Author

@gkalpak gkalpak Jun 7, 2016

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...

Copy link
Contributor

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

@Narretz
Copy link
Contributor

Narretz commented Jun 7, 2016

LGTM

1 similar comment
@petebacondarwin
Copy link
Contributor

LGTM

@petebacondarwin petebacondarwin modified the milestones: 1.5.x, Backlog Jun 7, 2016
@gkalpak gkalpak closed this in f3377da Jun 7, 2016
gkalpak added a commit that referenced this pull request Jun 7, 2016
@gkalpak gkalpak deleted the feat-ngMessageInclude-support-empty-template branch June 8, 2016 11:11
Narretz pushed a commit to Narretz/angular.js that referenced this pull request Jun 8, 2016
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.

ng-messages-include raises "Error: [jqLite:nosel]" when including empty file
4 participants