mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix(compiler): Allow startingTag method to handle text / comment nodes
This commit is contained in:
parent
6194e002e2
commit
3d0f11212f
2 changed files with 19 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -673,6 +673,13 @@ describe('angular', function() {
|
|||
toBe('<ng-abc x="2A">');
|
||||
});
|
||||
});
|
||||
|
||||
describe('startingTag', function() {
|
||||
it('should allow passing in Nodes instead of Elements', function() {
|
||||
var txtNode = document.createTextNode('some text');
|
||||
expect(startingTag(txtNode)).toBe('some text');
|
||||
});
|
||||
});
|
||||
|
||||
describe('snake_case', function(){
|
||||
it('should convert to snake_case', function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue