This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,9 @@ class TaggingCompiler implements Compiler {
68
68
} else if (node.nodeType == 3 || node.nodeType == 8 ) {
69
69
elementBinder = node.nodeType == 3 ? directives.selector.matchText (node) : elementBinder;
70
70
71
- if (elementBinder.hasDirectives && (node.parentNode != null && templateCursor.current.parentNode != null )) {
71
+ if (elementBinder != null &&
72
+ elementBinder.hasDirectives &&
73
+ (node.parentNode != null && templateCursor.current.parentNode != null )) {
72
74
if (directParentElementBinder == null ) {
73
75
74
76
directParentElementBinder = new TaggedElementBinder (null , parentElementBinderOffset);
@@ -84,10 +86,8 @@ class TaggingCompiler implements Compiler {
84
86
} else if (! (node.parentNode != null && templateCursor.current.parentNode != null )) { // Always add an elementBinder for top-level text.
85
87
elementBinders.add (new TaggedElementBinder (elementBinder, parentElementBinderOffset));
86
88
}
87
- // } else if (node.nodeType == 8) { // comment
88
-
89
89
} else {
90
- throw "wtf " ;
90
+ throw "Unsupported node type for $ node : [${ node . nodeType }] " ;
91
91
}
92
92
} while (templateCursor.moveNext () && domCursor.moveNext ());
93
93
Original file line number Diff line number Diff line change @@ -67,6 +67,18 @@ void main() {
67
67
$compile ([], directives);
68
68
}));
69
69
70
+ it ('should compile a comment with no directives around' , inject (() {
71
+ var element = $('<div><!-- comment --></div>' );
72
+ $compile (element, directives);
73
+ expect (element.html ()).toEqual ('<!-- comment -->' );
74
+ }));
75
+
76
+ it ('should compile a comment when the parent has a directive' , inject (() {
77
+ var element = $('<div ng-show="true"><!-- comment --></div>' );
78
+ $compile (element, directives);
79
+ expect (element.html ()).toEqual ('<!-- comment -->' );
80
+ }));
81
+
70
82
it ('should compile a directive in a child' , inject (() {
71
83
var element = $('<div><div ng-bind="name"></div></div>' );
72
84
var template = $compile (element, directives);
You can’t perform that action at this time.
0 commit comments