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

Commit b837fc3

Browse files
jbedardNarretz
authored andcommittedNov 7, 2015
refactor($compile): simplify multi element directive check
Previously, we would check if an attribute indicates a multi-element directive, now we only do this check if the attribute name actually matches the multi-element name pattern. Closes #12365
1 parent aff74ec commit b837fc3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed
 

‎src/ng/compile.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
12401240
return template.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol);
12411241
},
12421242
NG_ATTR_BINDING = /^ngAttr[A-Z]/;
1243+
var MULTI_ELEMENT_DIR_RE = /^(.+)Start$/;
12431244

12441245
compile.$$addBindingInfo = debugInfoEnabled ? function $$addBindingInfo($element, binding) {
12451246
var bindings = $element.data('$binding') || [];
@@ -1531,13 +1532,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
15311532
});
15321533
}
15331534

1534-
var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
1535-
if (directiveIsMultiElement(directiveNName)) {
1536-
if (ngAttrName === directiveNName + 'Start') {
1537-
attrStartName = name;
1538-
attrEndName = name.substr(0, name.length - 5) + 'end';
1539-
name = name.substr(0, name.length - 6);
1540-
}
1535+
var multiElementMatch = ngAttrName.match(MULTI_ELEMENT_DIR_RE);
1536+
if (multiElementMatch && directiveIsMultiElement(multiElementMatch[1])) {
1537+
attrStartName = name;
1538+
attrEndName = name.substr(0, name.length - 5) + 'end';
1539+
name = name.substr(0, name.length - 6);
15411540
}
15421541

15431542
nName = directiveNormalize(name.toLowerCase());

0 commit comments

Comments
 (0)