@angular-wave/angular.ts 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -0
- package/.eslintrc.cjs +29 -0
- package/.github/workflows/playwright.yml +27 -0
- package/CHANGELOG.md +17974 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +246 -0
- package/DEVELOPERS.md +488 -0
- package/LICENSE +22 -0
- package/Makefile +31 -0
- package/README.md +115 -0
- package/RELEASE.md +98 -0
- package/SECURITY.md +16 -0
- package/TRIAGING.md +135 -0
- package/css/angular.css +22 -0
- package/dist/angular-ts.cjs.js +36843 -0
- package/dist/angular-ts.esm.js +36841 -0
- package/dist/angular-ts.umd.js +36848 -0
- package/dist/build/angular-animate.js +4272 -0
- package/dist/build/angular-aria.js +426 -0
- package/dist/build/angular-message-format.js +1072 -0
- package/dist/build/angular-messages.js +829 -0
- package/dist/build/angular-mocks.js +3757 -0
- package/dist/build/angular-parse-ext.js +1275 -0
- package/dist/build/angular-resource.js +911 -0
- package/dist/build/angular-route.js +1266 -0
- package/dist/build/angular-sanitize.js +891 -0
- package/dist/build/angular-touch.js +368 -0
- package/dist/build/angular.js +36600 -0
- package/e2e/unit.spec.ts +15 -0
- package/images/android-chrome-192x192.png +0 -0
- package/images/android-chrome-512x512.png +0 -0
- package/images/apple-touch-icon.png +0 -0
- package/images/favicon-16x16.png +0 -0
- package/images/favicon-32x32.png +0 -0
- package/images/favicon.ico +0 -0
- package/images/site.webmanifest +1 -0
- package/index.html +104 -0
- package/package.json +47 -0
- package/playwright.config.ts +78 -0
- package/public/circle.html +1 -0
- package/public/my_child_directive.html +1 -0
- package/public/my_directive.html +1 -0
- package/public/my_other_directive.html +1 -0
- package/public/test.html +1 -0
- package/rollup.config.js +31 -0
- package/src/animations/animateCache.js +55 -0
- package/src/animations/animateChildrenDirective.js +105 -0
- package/src/animations/animateCss.js +1139 -0
- package/src/animations/animateCssDriver.js +291 -0
- package/src/animations/animateJs.js +367 -0
- package/src/animations/animateJsDriver.js +67 -0
- package/src/animations/animateQueue.js +851 -0
- package/src/animations/animation.js +506 -0
- package/src/animations/module.js +779 -0
- package/src/animations/ngAnimateSwap.js +119 -0
- package/src/animations/rafScheduler.js +50 -0
- package/src/animations/shared.js +378 -0
- package/src/constants.js +20 -0
- package/src/core/animate.js +845 -0
- package/src/core/animateCss.js +73 -0
- package/src/core/animateRunner.js +195 -0
- package/src/core/attributes.js +199 -0
- package/src/core/cache.js +45 -0
- package/src/core/compile.js +4727 -0
- package/src/core/controller.js +225 -0
- package/src/core/exceptionHandler.js +63 -0
- package/src/core/filter.js +146 -0
- package/src/core/interpolate.js +442 -0
- package/src/core/interval.js +188 -0
- package/src/core/intervalFactory.js +57 -0
- package/src/core/location.js +1086 -0
- package/src/core/parser/parse.js +2562 -0
- package/src/core/parser/parse.md +13 -0
- package/src/core/q.js +746 -0
- package/src/core/rootScope.js +1596 -0
- package/src/core/sanitizeUri.js +85 -0
- package/src/core/sce.js +1161 -0
- package/src/core/taskTrackerFactory.js +125 -0
- package/src/core/timeout.js +121 -0
- package/src/core/urlUtils.js +187 -0
- package/src/core/utils.js +1349 -0
- package/src/directive/a.js +37 -0
- package/src/directive/attrs.js +283 -0
- package/src/directive/bind.js +51 -0
- package/src/directive/bind.md +142 -0
- package/src/directive/change.js +12 -0
- package/src/directive/change.md +25 -0
- package/src/directive/cloak.js +12 -0
- package/src/directive/cloak.md +24 -0
- package/src/directive/events.js +75 -0
- package/src/directive/events.md +166 -0
- package/src/directive/form.js +725 -0
- package/src/directive/init.js +15 -0
- package/src/directive/init.md +41 -0
- package/src/directive/input.js +1783 -0
- package/src/directive/list.js +46 -0
- package/src/directive/list.md +22 -0
- package/src/directive/ngClass.js +249 -0
- package/src/directive/ngController.js +64 -0
- package/src/directive/ngCsp.js +82 -0
- package/src/directive/ngIf.js +134 -0
- package/src/directive/ngInclude.js +217 -0
- package/src/directive/ngModel.js +1356 -0
- package/src/directive/ngModelOptions.js +509 -0
- package/src/directive/ngOptions.js +670 -0
- package/src/directive/ngRef.js +90 -0
- package/src/directive/ngRepeat.js +650 -0
- package/src/directive/ngShowHide.js +255 -0
- package/src/directive/ngSwitch.js +178 -0
- package/src/directive/ngTransclude.js +98 -0
- package/src/directive/non-bindable.js +11 -0
- package/src/directive/non-bindable.md +17 -0
- package/src/directive/script.js +30 -0
- package/src/directive/select.js +624 -0
- package/src/directive/style.js +25 -0
- package/src/directive/style.md +23 -0
- package/src/directive/validators.js +329 -0
- package/src/exts/aria.js +544 -0
- package/src/exts/messages.js +852 -0
- package/src/filters/filter.js +207 -0
- package/src/filters/filter.md +69 -0
- package/src/filters/filters.js +239 -0
- package/src/filters/json.md +16 -0
- package/src/filters/limit-to.js +43 -0
- package/src/filters/limit-to.md +19 -0
- package/src/filters/order-by.js +183 -0
- package/src/filters/order-by.md +83 -0
- package/src/index.js +13 -0
- package/src/injector.js +1034 -0
- package/src/jqLite.js +1117 -0
- package/src/loader.js +1320 -0
- package/src/public.js +215 -0
- package/src/routeToRegExp.js +41 -0
- package/src/services/anchorScroll.js +135 -0
- package/src/services/browser.js +321 -0
- package/src/services/cacheFactory.js +398 -0
- package/src/services/cookieReader.js +72 -0
- package/src/services/document.js +64 -0
- package/src/services/http.js +1537 -0
- package/src/services/httpBackend.js +206 -0
- package/src/services/log.js +160 -0
- package/src/services/templateRequest.js +139 -0
- package/test/angular.spec.js +2153 -0
- package/test/aria/aria.spec.js +1245 -0
- package/test/binding.spec.js +504 -0
- package/test/build-test.html +14 -0
- package/test/injector.spec.js +2327 -0
- package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
- package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
- package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
- package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
- package/test/jasmine/jasmine-browser.json +17 -0
- package/test/jasmine/jasmine.json +9 -0
- package/test/jqlite.spec.js +2133 -0
- package/test/loader.spec.js +219 -0
- package/test/messages/messages.spec.js +1146 -0
- package/test/min-err.spec.js +174 -0
- package/test/mock-test.html +13 -0
- package/test/module-test.html +15 -0
- package/test/ng/anomate.spec.js +606 -0
- package/test/ng/cache-factor.spec.js +334 -0
- package/test/ng/compile.spec.js +17956 -0
- package/test/ng/controller-provider.spec.js +227 -0
- package/test/ng/cookie-reader.spec.js +98 -0
- package/test/ng/directive/a.spec.js +192 -0
- package/test/ng/directive/bind.spec.js +334 -0
- package/test/ng/directive/boolean.spec.js +136 -0
- package/test/ng/directive/change.spec.js +71 -0
- package/test/ng/directive/class.spec.js +858 -0
- package/test/ng/directive/click.spec.js +38 -0
- package/test/ng/directive/cloak.spec.js +44 -0
- package/test/ng/directive/constoller.spec.js +194 -0
- package/test/ng/directive/element-style.spec.js +92 -0
- package/test/ng/directive/event.spec.js +282 -0
- package/test/ng/directive/form.spec.js +1518 -0
- package/test/ng/directive/href.spec.js +143 -0
- package/test/ng/directive/if.spec.js +402 -0
- package/test/ng/directive/include.spec.js +828 -0
- package/test/ng/directive/init.spec.js +68 -0
- package/test/ng/directive/input.spec.js +3810 -0
- package/test/ng/directive/list.spec.js +170 -0
- package/test/ng/directive/model-options.spec.js +1008 -0
- package/test/ng/directive/model.spec.js +1905 -0
- package/test/ng/directive/non-bindable.spec.js +55 -0
- package/test/ng/directive/options.spec.js +3583 -0
- package/test/ng/directive/ref.spec.js +575 -0
- package/test/ng/directive/repeat.spec.js +1675 -0
- package/test/ng/directive/script.spec.js +52 -0
- package/test/ng/directive/scrset.spec.js +67 -0
- package/test/ng/directive/select.spec.js +2541 -0
- package/test/ng/directive/show-hide.spec.js +253 -0
- package/test/ng/directive/src.spec.js +157 -0
- package/test/ng/directive/style.spec.js +178 -0
- package/test/ng/directive/switch.spec.js +647 -0
- package/test/ng/directive/validators.spec.js +717 -0
- package/test/ng/document.spec.js +52 -0
- package/test/ng/filter/filter.spec.js +714 -0
- package/test/ng/filter/filters.spec.js +35 -0
- package/test/ng/filter/limit-to.spec.js +251 -0
- package/test/ng/filter/order-by.spec.js +891 -0
- package/test/ng/filter.spec.js +149 -0
- package/test/ng/http-backend.spec.js +398 -0
- package/test/ng/http.spec.js +4071 -0
- package/test/ng/interpolate.spec.js +642 -0
- package/test/ng/interval.spec.js +343 -0
- package/test/ng/location.spec.js +3488 -0
- package/test/ng/on.spec.js +229 -0
- package/test/ng/parse.spec.js +4655 -0
- package/test/ng/prop.spec.js +805 -0
- package/test/ng/q.spec.js +2904 -0
- package/test/ng/root-element.spec.js +16 -0
- package/test/ng/sanitize-uri.spec.js +249 -0
- package/test/ng/sce.spec.js +660 -0
- package/test/ng/scope.spec.js +3442 -0
- package/test/ng/template-request.spec.js +236 -0
- package/test/ng/timeout.spec.js +351 -0
- package/test/ng/url-utils.spec.js +156 -0
- package/test/ng/utils.spec.js +144 -0
- package/test/original-test.html +21 -0
- package/test/public.spec.js +34 -0
- package/test/sanitize/bing-html.spec.js +36 -0
- package/test/server/express.js +158 -0
- package/test/test-utils.js +11 -0
- package/tsconfig.json +17 -0
- package/types/angular.d.ts +138 -0
- package/types/global.d.ts +9 -0
- package/types/index.d.ts +2357 -0
- package/types/jqlite.d.ts +558 -0
- package/vite.config.js +14 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ngdoc service
|
|
3
|
+
* @name $animateCss
|
|
4
|
+
* @kind object
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
* This is the core version of `$animateCss`. By default, only when the `ngAnimate` is included,
|
|
9
|
+
* then the `$animateCss` service will actually perform animations.
|
|
10
|
+
*
|
|
11
|
+
* Click here {@link ngAnimate.$animateCss to read the documentation for $animateCss}.
|
|
12
|
+
*/
|
|
13
|
+
export function CoreAnimateCssProvider() {
|
|
14
|
+
this.$get = [
|
|
15
|
+
"$$AnimateRunner",
|
|
16
|
+
($$AnimateRunner) =>
|
|
17
|
+
function (element, initialOptions) {
|
|
18
|
+
// all of the animation functions should create
|
|
19
|
+
// a copy of the options data, however, if a
|
|
20
|
+
// parent service has already created a copy then
|
|
21
|
+
// we should stick to using that
|
|
22
|
+
let options = initialOptions || {};
|
|
23
|
+
if (!options.$$prepared) {
|
|
24
|
+
options = structuredClone(options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// there is no point in applying the styles since
|
|
28
|
+
// there is no animation that goes on at all in
|
|
29
|
+
// this version of $animateCss.
|
|
30
|
+
if (options.cleanupStyles) {
|
|
31
|
+
options.from = options.to = null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (options.from) {
|
|
35
|
+
//element.css(options.from);
|
|
36
|
+
options.from = null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let closed;
|
|
40
|
+
const runner = new $$AnimateRunner();
|
|
41
|
+
return {
|
|
42
|
+
start: run,
|
|
43
|
+
end: run,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function run() {
|
|
47
|
+
requestAnimationFrame(() => {
|
|
48
|
+
applyAnimationContents();
|
|
49
|
+
if (!closed) {
|
|
50
|
+
runner.complete();
|
|
51
|
+
}
|
|
52
|
+
closed = true;
|
|
53
|
+
});
|
|
54
|
+
return runner;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function applyAnimationContents() {
|
|
58
|
+
if (options.addClass) {
|
|
59
|
+
element[0].classList.add(options.addClass);
|
|
60
|
+
options.addClass = null;
|
|
61
|
+
}
|
|
62
|
+
if (options.removeClass) {
|
|
63
|
+
element[0].classList.remove(options.removeClass);
|
|
64
|
+
options.removeClass = null;
|
|
65
|
+
}
|
|
66
|
+
if (options.to) {
|
|
67
|
+
//element.css(options.to);
|
|
68
|
+
options.to = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { forEach } from "./utils";
|
|
2
|
+
|
|
3
|
+
export function AnimateAsyncRunFactoryProvider() {
|
|
4
|
+
this.$get = [
|
|
5
|
+
function () {
|
|
6
|
+
var waitQueue = [];
|
|
7
|
+
|
|
8
|
+
function waitForTick(fn) {
|
|
9
|
+
waitQueue.push(fn);
|
|
10
|
+
if (waitQueue.length > 1) return;
|
|
11
|
+
window.requestAnimationFrame(function () {
|
|
12
|
+
for (var i = 0; i < waitQueue.length; i++) {
|
|
13
|
+
waitQueue[i]();
|
|
14
|
+
}
|
|
15
|
+
waitQueue = [];
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return function () {
|
|
20
|
+
var passed = false;
|
|
21
|
+
waitForTick(function () {
|
|
22
|
+
passed = true;
|
|
23
|
+
});
|
|
24
|
+
return function (callback) {
|
|
25
|
+
if (passed) {
|
|
26
|
+
callback();
|
|
27
|
+
} else {
|
|
28
|
+
waitForTick(callback);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function AnimateRunnerFactoryProvider() {
|
|
37
|
+
this.$get = [
|
|
38
|
+
"$q",
|
|
39
|
+
"$$animateAsyncRun",
|
|
40
|
+
"$$isDocumentHidden",
|
|
41
|
+
"$timeout",
|
|
42
|
+
function ($q, $$animateAsyncRun, $$isDocumentHidden, $timeout) {
|
|
43
|
+
const INITIAL_STATE = 0;
|
|
44
|
+
const DONE_PENDING_STATE = 1;
|
|
45
|
+
const DONE_COMPLETE_STATE = 2;
|
|
46
|
+
|
|
47
|
+
AnimateRunner.chain = function (chain, callback) {
|
|
48
|
+
let index = 0;
|
|
49
|
+
|
|
50
|
+
next();
|
|
51
|
+
function next() {
|
|
52
|
+
if (index === chain.length) {
|
|
53
|
+
callback(true);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
chain[index]((response) => {
|
|
58
|
+
if (response === false) {
|
|
59
|
+
callback(false);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
index++;
|
|
63
|
+
next();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
AnimateRunner.all = function (runners, callback) {
|
|
69
|
+
let count = 0;
|
|
70
|
+
let status = true;
|
|
71
|
+
forEach(runners, (runner) => {
|
|
72
|
+
runner.done(onProgress);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
function onProgress(response) {
|
|
76
|
+
status = status && response;
|
|
77
|
+
if (++count === runners.length) {
|
|
78
|
+
callback(status);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
function AnimateRunner(host) {
|
|
84
|
+
this.setHost(host);
|
|
85
|
+
|
|
86
|
+
const rafTick = $$animateAsyncRun();
|
|
87
|
+
const timeoutTick = function (fn) {
|
|
88
|
+
$timeout(fn, 0, false);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
this._doneCallbacks = [];
|
|
92
|
+
this._tick = function (fn) {
|
|
93
|
+
if ($$isDocumentHidden()) {
|
|
94
|
+
timeoutTick(fn);
|
|
95
|
+
} else {
|
|
96
|
+
rafTick(fn);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
this._state = 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
AnimateRunner.prototype = {
|
|
103
|
+
setHost(host) {
|
|
104
|
+
this.host = host || {};
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
done(fn) {
|
|
108
|
+
if (this._state === DONE_COMPLETE_STATE) {
|
|
109
|
+
fn();
|
|
110
|
+
} else {
|
|
111
|
+
this._doneCallbacks.push(fn);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
progress: () => {},
|
|
116
|
+
|
|
117
|
+
getPromise() {
|
|
118
|
+
if (!this.promise) {
|
|
119
|
+
const self = this;
|
|
120
|
+
this.promise = $q((resolve, reject) => {
|
|
121
|
+
self.done((status) => {
|
|
122
|
+
if (status === false) {
|
|
123
|
+
reject();
|
|
124
|
+
} else {
|
|
125
|
+
resolve();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return this.promise;
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
then(resolveHandler, rejectHandler) {
|
|
134
|
+
return this.getPromise().then(resolveHandler, rejectHandler);
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
catch(handler) {
|
|
138
|
+
return this.getPromise().catch(handler);
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
finally(handler) {
|
|
142
|
+
return this.getPromise().finally(handler);
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
pause() {
|
|
146
|
+
if (this.host.pause) {
|
|
147
|
+
this.host.pause();
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
resume() {
|
|
152
|
+
if (this.host.resume) {
|
|
153
|
+
this.host.resume();
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
end() {
|
|
158
|
+
if (this.host.end) {
|
|
159
|
+
this.host.end();
|
|
160
|
+
}
|
|
161
|
+
this._resolve(true);
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
cancel() {
|
|
165
|
+
if (this.host.cancel) {
|
|
166
|
+
this.host.cancel();
|
|
167
|
+
}
|
|
168
|
+
this._resolve(false);
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
complete(response) {
|
|
172
|
+
const self = this;
|
|
173
|
+
if (self._state === INITIAL_STATE) {
|
|
174
|
+
self._state = DONE_PENDING_STATE;
|
|
175
|
+
self._tick(() => {
|
|
176
|
+
self._resolve(response);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
_resolve(response) {
|
|
182
|
+
if (this._state !== DONE_COMPLETE_STATE) {
|
|
183
|
+
forEach(this._doneCallbacks, (fn) => {
|
|
184
|
+
fn(response);
|
|
185
|
+
});
|
|
186
|
+
this._doneCallbacks.length = 0;
|
|
187
|
+
this._state = DONE_COMPLETE_STATE;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return AnimateRunner;
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
export class Attributes {
|
|
2
|
+
constructor(element, attributesToCopy) {
|
|
3
|
+
if (attributesToCopy) {
|
|
4
|
+
const keys = Object.keys(attributesToCopy);
|
|
5
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
6
|
+
const key = keys[i];
|
|
7
|
+
this[key] = attributesToCopy[key];
|
|
8
|
+
}
|
|
9
|
+
} else {
|
|
10
|
+
this.$attr = {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
this.$$element = element;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @ngdoc method
|
|
18
|
+
* @name $compile.directive.Attributes#$normalize
|
|
19
|
+
* @kind function
|
|
20
|
+
*
|
|
21
|
+
* @description
|
|
22
|
+
* Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with `x-` or
|
|
23
|
+
* `data-`) to its normalized, camelCase form.
|
|
24
|
+
*
|
|
25
|
+
* Also there is special case for Moz prefix starting with upper case letter.
|
|
26
|
+
*
|
|
27
|
+
* For further information check out the guide on {@link guide/directive#matching-directives Matching Directives}
|
|
28
|
+
*
|
|
29
|
+
* @param {string} name Name to normalize
|
|
30
|
+
*/
|
|
31
|
+
$normalize(name) {
|
|
32
|
+
return directiveNormalize(name);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @ngdoc method
|
|
37
|
+
* @name $compile.directive.Attributes#$addClass
|
|
38
|
+
* @kind function
|
|
39
|
+
*
|
|
40
|
+
* @description
|
|
41
|
+
* Adds the CSS class value specified by the classVal parameter to the element. If animations
|
|
42
|
+
* are enabled then an animation will be triggered for the class addition.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} classVal The className value that will be added to the element
|
|
45
|
+
*/
|
|
46
|
+
$addClass(classVal) {
|
|
47
|
+
if (classVal && classVal.length > 0) {
|
|
48
|
+
$animate.addClass(this.$$element, classVal);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @ngdoc method
|
|
54
|
+
* @name $compile.directive.Attributes#$removeClass
|
|
55
|
+
* @kind function
|
|
56
|
+
*
|
|
57
|
+
* @description
|
|
58
|
+
* Removes the CSS class value specified by the classVal parameter from the element. If
|
|
59
|
+
* animations are enabled then an animation will be triggered for the class removal.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} classVal The className value that will be removed from the element
|
|
62
|
+
*/
|
|
63
|
+
$removeClass(classVal) {
|
|
64
|
+
if (classVal && classVal.length > 0) {
|
|
65
|
+
$animate.removeClass(this.$$element, classVal);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @ngdoc method
|
|
71
|
+
* @name $compile.directive.Attributes#$updateClass
|
|
72
|
+
* @kind function
|
|
73
|
+
*
|
|
74
|
+
* @description
|
|
75
|
+
* Adds and removes the appropriate CSS class values to the element based on the difference
|
|
76
|
+
* between the new and old CSS class values (specified as newClasses and oldClasses).
|
|
77
|
+
*
|
|
78
|
+
* @param {string} newClasses The current CSS className value
|
|
79
|
+
* @param {string} oldClasses The former CSS className value
|
|
80
|
+
*/
|
|
81
|
+
$updateClass(newClasses, oldClasses) {
|
|
82
|
+
const toAdd = tokenDifference(newClasses, oldClasses);
|
|
83
|
+
if (toAdd && toAdd.length) {
|
|
84
|
+
$animate.addClass(this.$$element, toAdd);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const toRemove = tokenDifference(oldClasses, newClasses);
|
|
88
|
+
if (toRemove && toRemove.length) {
|
|
89
|
+
$animate.removeClass(this.$$element, toRemove);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Set a normalized attribute on the element in a way such that all directives
|
|
95
|
+
* can share the attribute. This function properly handles boolean attributes.
|
|
96
|
+
* @param {string} key Normalized key. (ie ngAttribute)
|
|
97
|
+
* @param {string|boolean} value The value to set. If `null` attribute will be deleted.
|
|
98
|
+
* @param {boolean=} writeAttr If false, does not write the value to DOM element attribute.
|
|
99
|
+
* Defaults to true.
|
|
100
|
+
* @param {string=} attrName Optional none normalized name. Defaults to key.
|
|
101
|
+
*/
|
|
102
|
+
$set(key, value, writeAttr = true, attrName) {
|
|
103
|
+
const node = this.$$element[0];
|
|
104
|
+
const booleanKey = getBooleanAttrName(node, key);
|
|
105
|
+
const aliasedKey = ALIASED_ATTR[key];
|
|
106
|
+
let observer = key;
|
|
107
|
+
let nodeName;
|
|
108
|
+
|
|
109
|
+
if (booleanKey) {
|
|
110
|
+
this.$$element.prop(key, value);
|
|
111
|
+
attrName = booleanKey;
|
|
112
|
+
} else if (aliasedKey) {
|
|
113
|
+
this[aliasedKey] = value;
|
|
114
|
+
observer = aliasedKey;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this[key] = value;
|
|
118
|
+
|
|
119
|
+
if (attrName) {
|
|
120
|
+
this.$attr[key] = attrName;
|
|
121
|
+
} else {
|
|
122
|
+
attrName = this.$attr[key];
|
|
123
|
+
if (!attrName) {
|
|
124
|
+
this.$attr[key] = attrName = snakeCase(key, "-");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
nodeName = nodeName_(this.$$element);
|
|
129
|
+
|
|
130
|
+
if (nodeName === "img" && key === "srcset") {
|
|
131
|
+
this[key] = value = sanitizeSrcset(value, "$set('srcset', value)");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (writeAttr !== false) {
|
|
135
|
+
if (value === null || isUndefined(value)) {
|
|
136
|
+
this.$$element[0].removeAttribute(attrName);
|
|
137
|
+
} else if (SIMPLE_ATTR_NAME.test(attrName)) {
|
|
138
|
+
if (booleanKey && value === false) {
|
|
139
|
+
this.$$element[0].removeAttribute(attrName);
|
|
140
|
+
} else {
|
|
141
|
+
this.$$element.attr(attrName, value);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
setSpecialAttr(this.$$element[0], attrName, value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const { $$observers } = this;
|
|
149
|
+
if ($$observers) {
|
|
150
|
+
forEach($$observers[observer], (fn) => {
|
|
151
|
+
try {
|
|
152
|
+
fn(value);
|
|
153
|
+
} catch (e) {
|
|
154
|
+
$exceptionHandler(e);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @ngdoc method
|
|
162
|
+
* @name $compile.directive.Attributes#$observe
|
|
163
|
+
* @kind function
|
|
164
|
+
*
|
|
165
|
+
* @description
|
|
166
|
+
* Observes an interpolated attribute.
|
|
167
|
+
*
|
|
168
|
+
* The observer function will be invoked once during the next `$digest` following
|
|
169
|
+
* compilation. The observer is then invoked whenever the interpolated value
|
|
170
|
+
* changes.
|
|
171
|
+
*
|
|
172
|
+
* @param {string} key Normalized key. (ie ngAttribute) .
|
|
173
|
+
* @param {function(interpolatedValue)} fn Function that will be called whenever
|
|
174
|
+
the interpolated value of the attribute changes.
|
|
175
|
+
* See the {@link guide/interpolation#how-text-and-attribute-bindings-work Interpolation
|
|
176
|
+
* guide} for more info.
|
|
177
|
+
* @returns {function()} Returns a deregistration function for this observer.
|
|
178
|
+
*/
|
|
179
|
+
$observe(key, fn) {
|
|
180
|
+
const attrs = this;
|
|
181
|
+
const $$observers = attrs.$$observers || (attrs.$$observers = createMap());
|
|
182
|
+
const listeners = $$observers[key] || ($$observers[key] = []);
|
|
183
|
+
|
|
184
|
+
listeners.push(fn);
|
|
185
|
+
$rootScope.$evalAsync(() => {
|
|
186
|
+
if (
|
|
187
|
+
!listeners.$$inter &&
|
|
188
|
+
Object.prototype.hasOwnProperty.call(attrs, key) &&
|
|
189
|
+
!isUndefined(attrs[key])
|
|
190
|
+
) {
|
|
191
|
+
fn(attrs[key]);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return function () {
|
|
196
|
+
arrayRemove(listeners, fn);
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} ExpandoStore
|
|
3
|
+
*
|
|
4
|
+
* @property {!Object<string, any>} data
|
|
5
|
+
* @property {!Object} events
|
|
6
|
+
* @property {?Function} handle
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Expando cache for adding properties to DOM nodes with JavaScript.
|
|
12
|
+
* This used to be an Object in JQLite decorator, but swapped out for a Map
|
|
13
|
+
* for performance reasons and convenience methods. A proxy is available for
|
|
14
|
+
* additional logic handling.
|
|
15
|
+
*
|
|
16
|
+
* @type {Map<number, ExpandoStore>}
|
|
17
|
+
*/
|
|
18
|
+
export const CACHE = new Proxy(new Map(), {
|
|
19
|
+
get(target, prop, receiver) {
|
|
20
|
+
if (prop === "size") {
|
|
21
|
+
return target.size;
|
|
22
|
+
}
|
|
23
|
+
if (typeof target[prop] === "function") {
|
|
24
|
+
return function (...args) {
|
|
25
|
+
return target[prop].apply(target, args);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return Reflect.get(target, prop, receiver);
|
|
29
|
+
},
|
|
30
|
+
set(target, prop, value, receiver) {
|
|
31
|
+
return Reflect.set(target, prop, value, receiver);
|
|
32
|
+
},
|
|
33
|
+
deleteProperty(target, prop) {
|
|
34
|
+
return Reflect.deleteProperty(target, prop);
|
|
35
|
+
},
|
|
36
|
+
has(target, prop) {
|
|
37
|
+
return Reflect.has(target, prop);
|
|
38
|
+
},
|
|
39
|
+
ownKeys(target) {
|
|
40
|
+
return Reflect.ownKeys(target);
|
|
41
|
+
},
|
|
42
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
43
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
44
|
+
},
|
|
45
|
+
});
|