Skip to content

Commit

Permalink
refactor($compile): simplify multi element directive check
Browse files Browse the repository at this point in the history
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 angular#12365
  • Loading branch information
jbedard authored and gkalpak committed Nov 23, 2015
1 parent 9d1b201 commit 900d351
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
return template.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol);
},
NG_ATTR_BINDING = /^ngAttr[A-Z]/;
var MULTI_ELEMENT_DIR_RE = /^(.+)Start$/;

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

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

nName = directiveNormalize(name.toLowerCase());
Expand Down

0 comments on commit 900d351

Please sign in to comment.