Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(Angular): properly get node name for svg element wrapper #10172

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ function makeMap(str) {


function nodeName_(element) {
return lowercase(element.nodeName || element[0].nodeName);
return lowercase(element.nodeName || (element[0] && element[0].nodeName));
}

function includes(array, obj) {
Expand Down
5 changes: 5 additions & 0 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,11 @@ describe('angular', function() {
expect(nodeName_(div.childNodes[0])).toBe('ngtest:foo');
expect(div.childNodes[0].getAttribute('ngtest:attr')).toBe('bar');
});

it('should return undefined for elements without the .nodeName property', function() {
//some elements, like SVGElementInstance don't have .nodeName property
expect(nodeName_({})).toBeUndefined();
});
});


Expand Down