Skip to content

Commit 2f44477

Browse files
fix($compile): support merging special attribute names in replace directives
When compiling a `replace` directive, the compiler merges the attributes from the replaced element onto the template element. Unfortunately, `setAttribute` and other related DOM methods do not allow certain attribute names - in particular Angular 2 style names such as `(click)` and `[value]`. This is relevant when using ngForward with Angular Material, since the `mgButton` directive uses `replace` and in the former you often use `(click)`. This fixes the problem but for those special attributes the speed is considerably slow. Closes angular#13317 Closes angular#13318
1 parent fbfa14a commit 2f44477

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/ng/compile.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
990990
$controller, $rootScope, $document, $sce, $animate, $$sanitizeUri) {
991991

992992
var SIMPLE_ATTR_NAME = /^\w/;
993-
var QUOTE_REGEX = /'/g;
994993
var specialAttrHolder = document.createElement('div');
995994
var Attributes = function(element, attributesToCopy) {
996995
if (attributesToCopy) {
@@ -1229,7 +1228,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
12291228
};
12301229

12311230
function setSpecialAttr(element, attrName, value) {
1232-
// Attributes names that do not start with letters cannot be set using `setAttribute`
1231+
// Attributes names that do not start with letters (such as `(click)`) cannot be set using `setAttribute`
12331232
// so we have to jump through some hoops to get such an attribute
12341233
// https://github.com/angular/angular.js/pull/13318
12351234
specialAttrHolder.innerHTML = "<span " + attrName + ">";

0 commit comments

Comments
 (0)