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

fix($scope): fixes multiple root element error when there is a whites… #15132

Conversation

renovatorruler
Copy link
Contributor

@renovatorruler renovatorruler commented Sep 14, 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)
If one tries to load a directive with a top-level comment angular throws an error
Error: [$compile:tplrt] Template for directive 'myDirective' must have exactly one root element
#15108

Does this PR introduce a breaking change?
No

Please check if the PR fulfills these requirements

Other information:

fixes multiple root element error when there is a whitespace after a comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes #15108

@Narretz
Copy link
Contributor

Narretz commented Sep 14, 2016

This issue doesn't only happen with replace directives, but with any directive that has a comment node with whitespace around it. I think these two tests should be added:

            // comments are ok
            $templateCache.put('template.html', '<!-- oh hi --><div></div> \n');
            $compile('<p template></p>');
            $rootScope.$apply();
            expect($exceptionHandler.errors).toEqual([]);

            // white space around comments is ok
            $templateCache.put('template.html', '  <!-- oh hi -->  <div></div>  <!-- oh hi -->\n');
            $compile('<p template></p>');
            $rootScope.$apply();
            expect($exceptionHandler.errors).toEqual([]);

for the test it('should fail if replacing and template doesn\'t have a single root element'

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

1 similar comment
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@renovatorruler renovatorruler force-pushed the bugfix/15108-directive-template-with-space branch from 32886b1 to a43d34e Compare September 14, 2016 18:03
@googlebot
Copy link

CLAs look good, thanks!

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

…pace after a comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes angular#15108

Removing accidental fdescribe
@renovatorruler renovatorruler force-pushed the bugfix/15108-directive-template-with-space branch from a43d34e to f01e07c Compare September 14, 2016 19:46
@renovatorruler
Copy link
Contributor Author

@Narretz Added those tests

@Narretz
Copy link
Contributor

Narretz commented Sep 14, 2016

@prashantpawar Sorry, you are right, it's all replace directives. It looks like these tests are duplicated in a few places.

@Narretz Narretz merged commit 76d3daf into angular:master Sep 15, 2016
Narretz pushed a commit that referenced this pull request Sep 15, 2016
…d a top-level comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes #15108
PR (#15132)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…d a top-level comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes angular#15108
PR (angular#15132)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…d a top-level comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes angular#15108
PR (angular#15132)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…d a top-level comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes angular#15108
PR (angular#15132)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…d a top-level comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes angular#15108
PR (angular#15132)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…d a top-level comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes angular#15108
PR (angular#15132)
petebacondarwin pushed a commit that referenced this pull request Nov 23, 2016
…d a top-level comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes #15108
PR (#15132)
petebacondarwin pushed a commit that referenced this pull request Nov 24, 2016
…d a top-level comment

Added new conditional for NODE_TYPE_TEXT inside removeComments method of $compile
Added corresponding unit tests.

Closes #15108
PR (#15132)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants