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

fix($compile): Fix namespace detection for achor elements #13480

Closed
wants to merge 1 commit into from
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/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
if (!node) {
return 'html';
} else {
return nodeName_(node) !== 'foreignobject' && node.toString().match(/SVG/) ? 'svg' : 'html';
return nodeName_(node) !== 'foreignobject' && toString.call(node).match(/SVG/) ? 'svg' : 'html';
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ng/directive/ngInclude.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ var ngIncludeFillContentDirective = ['$compile',
priority: -400,
require: 'ngInclude',
link: function(scope, $element, $attr, ctrl) {
if (/SVG/.test($element[0].toString())) {
if (toString.call($element[0]).match(/SVG/)) {
// WebKit: https://bugs.webkit.org/show_bug.cgi?id=135698 --- SVG elements do not
// support innerHTML, so detect this here and try to generate the contents
// specially.
Expand Down
10 changes: 9 additions & 1 deletion test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ describe('$compile', function() {
});
});


describe('compile phase', function() {

it('should attach scope to the document node when it is compiled explicitly', inject(function($document) {
Expand Down Expand Up @@ -444,6 +443,15 @@ describe('$compile', function() {
expect(element.html()).toBe("3");
}));

it('transclusions should not detect parent anchor elements as SVGs', inject(function($compile, $rootScope) {
element = jqLite('<div><a href="/ID_SVG_ID">' +
'<span ng-if="true">Should render</span>' +
'</a></div>');
$compile(element.contents())($rootScope);
$rootScope.$digest();
document.body.appendChild(element[0]);
expect(element.find('span').text()).toContain('Should render');
}));

describe('multiple directives per element', function() {
it('should allow multiple directives per element', inject(function($compile, $rootScope, log) {
Expand Down