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

Commit 91ef94d

Browse files
jbedardpetebacondarwin
authored andcommitted
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 ab9b021 commit 91ef94d

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') || [];
@@ -1524,13 +1525,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
15241525
});
15251526
}
15261527

1527-
var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
1528-
if (directiveIsMultiElement(directiveNName)) {
1529-
if (ngAttrName === directiveNName + 'Start') {
1530-
attrStartName = name;
1531-
attrEndName = name.substr(0, name.length - 5) + 'end';
1532-
name = name.substr(0, name.length - 6);
1533-
}
1528+
var multiElementMatch = ngAttrName.match(MULTI_ELEMENT_DIR_RE);
1529+
if (multiElementMatch && directiveIsMultiElement(multiElementMatch[1])) {
1530+
attrStartName = name;
1531+
attrEndName = name.substr(0, name.length - 5) + 'end';
1532+
name = name.substr(0, name.length - 6);
15341533
}
15351534

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

0 commit comments

Comments
 (0)