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

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

Closed
0xDCA opened this issue Sep 25, 2015 · 4 comments
Closed

Comments

@0xDCA
Copy link

0xDCA commented Sep 25, 2015

As shown in http://plnkr.co/edit/VFrt4rXZaK194zwJg0P2?p=preview, the ng-messages-include directive attempts to call angular.element() with the content of the file (empty or spaces) and, because jqLite interprets every string that does not start with "<" as a selector, it will raise an error.

The error will be raised if the included file is not empty but starts with a text. I am not sure if angular-messages should handle the case where the included file contains text outside a <div ng-message="..."></div>, but I believe it should handle empty files gracefully.

@Narretz
Copy link
Contributor

Narretz commented Sep 25, 2015

Do you mean it should throw a more descriptive error or ...?

@0xDCA
Copy link
Author

0xDCA commented Sep 25, 2015

Sorry for being unclear.

I believe it shouldn't throw an error for this case.
I faced this issue when testing a custom directive. As I am adding messages from multiple files (i.e multiple <div ng-messages-include="..."></div>, I would like to test that they're added, and that they're added in the correct order. For the first case (just testing that messages are added from some custom sources), I just fill one of the sources with messages and leave the other ones empty.

It's easy to workaround (I can just add <div></div> to the 'empty' sources), but I wonder if it should fail at all.

@Narretz
Copy link
Contributor

Narretz commented Sep 29, 2015

If you want to open a PR with this change, I'd be happy to look at it.

@gkalpak
Copy link
Member

gkalpak commented Jun 7, 2016

There you go #14726 😃

@gkalpak gkalpak closed this as completed in f3377da Jun 7, 2016
Narretz pushed a commit to Narretz/angular.js that referenced this issue 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 a pull request may close this issue.

3 participants