mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 23:34:42 +00:00
refactor(booleanAttrs, ngSwitch): use link function instead of compile function where appropriate
Replace two compile functions that immediately return a post-link function with link function definitions instead. Closes #5664
This commit is contained in:
parent
e115342fce
commit
5df7e73adf
2 changed files with 7 additions and 11 deletions
|
|
@ -336,12 +336,10 @@ forEach(BOOLEAN_ATTR, function(propName, attrName) {
|
||||||
ngAttributeAliasDirectives[normalized] = function() {
|
ngAttributeAliasDirectives[normalized] = function() {
|
||||||
return {
|
return {
|
||||||
priority: 100,
|
priority: 100,
|
||||||
compile: function() {
|
link: function(scope, element, attr) {
|
||||||
return function(scope, element, attr) {
|
scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) {
|
||||||
scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) {
|
attr.$set(attrName, !!value);
|
||||||
attr.$set(attrName, !!value);
|
});
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -168,11 +168,9 @@ var ngSwitchWhenDirective = ngDirective({
|
||||||
transclude: 'element',
|
transclude: 'element',
|
||||||
priority: 800,
|
priority: 800,
|
||||||
require: '^ngSwitch',
|
require: '^ngSwitch',
|
||||||
compile: function(element, attrs) {
|
link: function(scope, element, attrs, ctrl, $transclude) {
|
||||||
return function(scope, element, attr, ctrl, $transclude) {
|
ctrl.cases['!' + attrs.ngSwitchWhen] = (ctrl.cases['!' + attrs.ngSwitchWhen] || []);
|
||||||
ctrl.cases['!' + attrs.ngSwitchWhen] = (ctrl.cases['!' + attrs.ngSwitchWhen] || []);
|
ctrl.cases['!' + attrs.ngSwitchWhen].push({ transclude: $transclude, element: element });
|
||||||
ctrl.cases['!' + attrs.ngSwitchWhen].push({ transclude: $transclude, element: element });
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue