diff options
| -rw-r--r-- | src/jqLite.js | 3 | ||||
| -rw-r--r-- | test/jqLiteSpec.js | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/jqLite.js b/src/jqLite.js index e5980514..f48dd3c0 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -175,6 +175,9 @@ function JQLite(element) { if (element instanceof JQLite) { return element; } + if (isString(element)) { + element = trim(element); + } if (!(this instanceof JQLite)) { if (isString(element) && element.charAt(0) != '<') { throw jqLiteMinErr('nosel', 'Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element'); 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); |
