From 755beb2b66ce9f9f9a218f2355bbaf96d94fbc15 Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Sat, 19 Jan 2013 10:21:17 +0530 Subject: fix(compiler): Allow startingTag method to handle text / comment nodes --- src/Angular.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/Angular.js') diff --git a/src/Angular.js b/src/Angular.js index 27ef157d..5195489e 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -777,9 +777,18 @@ function startingTag(element) { // are not allowed to have children. So we just ignore it. element.html(''); } catch(e) {} - return jqLite('
').append(element).html(). - match(/^(<[^>]+>)/)[1]. - replace(/^<([\w\-]+)/, function(match, nodeName) { return '<' + lowercase(nodeName); }); + // As Per DOM Standards + var TEXT_NODE = 3; + var elemHtml = jqLite('
').append(element).html(); + try { + return element[0].nodeType === TEXT_NODE ? lowercase(elemHtml) : + elemHtml. + match(/^(<[^>]+>)/)[1]. + replace(/^<([\w\-]+)/, function(match, nodeName) { return '<' + lowercase(nodeName); }); + } catch(e) { + return lowercase(elemHtml); + } + } -- cgit v1.2.3