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

Commit 5df7e73

Browse files
Gias Kay Leetbosch
Gias Kay Lee
authored andcommitted
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
1 parent e115342 commit 5df7e73

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/ng/directive/booleanAttrs.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,10 @@ forEach(BOOLEAN_ATTR, function(propName, attrName) {
336336
ngAttributeAliasDirectives[normalized] = function() {
337337
return {
338338
priority: 100,
339-
compile: function() {
340-
return function(scope, element, attr) {
341-
scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) {
342-
attr.$set(attrName, !!value);
343-
});
344-
};
339+
link: function(scope, element, attr) {
340+
scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) {
341+
attr.$set(attrName, !!value);
342+
});
345343
}
346344
};
347345
};

src/ng/directive/ngSwitch.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,9 @@ var ngSwitchWhenDirective = ngDirective({
168168
transclude: 'element',
169169
priority: 800,
170170
require: '^ngSwitch',
171-
compile: function(element, attrs) {
172-
return function(scope, element, attr, ctrl, $transclude) {
173-
ctrl.cases['!' + attrs.ngSwitchWhen] = (ctrl.cases['!' + attrs.ngSwitchWhen] || []);
174-
ctrl.cases['!' + attrs.ngSwitchWhen].push({ transclude: $transclude, element: element });
175-
};
171+
link: function(scope, element, attrs, ctrl, $transclude) {
172+
ctrl.cases['!' + attrs.ngSwitchWhen] = (ctrl.cases['!' + attrs.ngSwitchWhen] || []);
173+
ctrl.cases['!' + attrs.ngSwitchWhen].push({ transclude: $transclude, element: element });
176174
}
177175
});
178176

0 commit comments

Comments
 (0)