aboutsummaryrefslogtreecommitdiffstats
path: root/test/jqLiteSpec.js
diff options
context:
space:
mode:
authorCaitlin Potter2014-02-04 11:37:09 -0500
committerVojta Jina2014-02-04 16:39:52 -0800
commit36d37c0e3880c774d20c014ade60d2331beefa15 (patch)
treeacf5a90799f618a9be823a6a8dbcf23ba092e095 /test/jqLiteSpec.js
parent24699ee8f04c1f1459be1d36207e654421d58ff0 (diff)
downloadangular.js-36d37c0e3880c774d20c014ade60d2331beefa15.tar.bz2
fix(jqLite): trim HTML string in jqLite constructor
jQuery will construct DOM nodes containing leading whitespace. Prior to this change, jqLite would throw a nosel minErr due to the first character of the string not being '<'. This change corrects this behaviour by trimming the element string in jqLite constructor before testing for '<'. Closes #6053
Diffstat (limited to 'test/jqLiteSpec.js')
-rw-r--r--test/jqLiteSpec.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index 931f9b2e..a98e94b9 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -65,6 +65,17 @@ describe('jqLite', function() {
});
+ it('should allow construction of html with leading whitespace', function() {
+ var nodes = jqLite(' \n\r \r\n<div>1</div><span>2</span>');
+ expect(nodes[0].parentNode).toBeDefined();
+ expect(nodes[0].parentNode.nodeType).toBe(11); /** Document Fragment **/;
+ expect(nodes[0].parentNode).toBe(nodes[1].parentNode);
+ expect(nodes.length).toBe(2);
+ expect(nodes[0].innerHTML).toBe('1');
+ expect(nodes[1].innerHTML).toBe('2');
+ });
+
+
it('should allow creation of comment tags', function() {
var nodes = jqLite('<!-- foo -->');
expect(nodes.length).toBe(1);