aboutsummaryrefslogtreecommitdiffstats
path: root/src/Angular.js
diff options
context:
space:
mode:
authorShyam Seshadri2013-01-19 10:21:17 +0530
committerMisko Hevery2013-02-14 14:43:55 -0800
commit755beb2b66ce9f9f9a218f2355bbaf96d94fbc15 (patch)
tree77e304cf39020d89ac4fd6fb1c8917d85976a76a /src/Angular.js
parent6d70ff5c8d1e032ca7d29c48ca55882a64ca1487 (diff)
downloadangular.js-755beb2b66ce9f9f9a218f2355bbaf96d94fbc15.tar.bz2
fix(compiler): Allow startingTag method to handle text / comment nodes
Diffstat (limited to 'src/Angular.js')
-rw-r--r--src/Angular.js15
1 files changed, 12 insertions, 3 deletions
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('<div>').append(element).html().
- match(/^(<[^>]+>)/)[1].
- replace(/^<([\w\-]+)/, function(match, nodeName) { return '<' + lowercase(nodeName); });
+ // As Per DOM Standards
+ var TEXT_NODE = 3;
+ var elemHtml = jqLite('<div>').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);
+ }
+
}