@angular-wave/angular.ts 0.0.38 → 0.0.40
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/Makefile +8 -5
- package/README.md +1 -1
- package/dist/angular-ts.esm.js +2 -1
- package/dist/angular-ts.umd.js +2 -1
- package/package.json +2 -4
- package/rollup.config.js +11 -2
- package/src/angular.spec.js +25 -26
- package/src/animations/animate-css-driver.js +3 -3
- package/src/animations/animate-queue.js +7 -7
- package/src/animations/animation.js +2 -2
- package/src/animations/shared.js +6 -6
- package/src/binding.spec.js +7 -7
- package/src/core/animate/animate.js +5 -5
- package/src/core/animate/animate.spec.js +31 -31
- package/src/core/cache/cache-factory.html +18 -0
- package/src/core/cache/{cache-factor.test.js → cache-factory.test.js} +1 -1
- package/src/core/compile/compile.js +31 -25
- package/src/core/compile/compile.md +2 -2
- package/src/core/cookie-reader.spec.js +2 -2
- package/src/core/core.html +22 -0
- package/src/core/core.test.js +12 -0
- package/src/core/document.spec.js +4 -4
- package/src/core/exception-handler.js +30 -23
- package/src/core/interpolate/interpolate.js +7 -0
- package/src/core/{cache/cache-factor.html → location/location.html} +1 -1
- package/src/core/location/location.js +2 -2
- package/src/core/location/location.spec.js +17 -17
- package/src/core/location/location.test.js +12 -0
- package/src/core/on.spec.js +3 -3
- package/src/core/parser/parse.html +18 -0
- package/src/core/parser/parse.spec.js +1 -1
- package/src/core/parser/parse.test.js +12 -0
- package/src/core/prop.spec.js +3 -4
- package/src/core/pubsub/pubsub.html +18 -0
- package/src/core/pubsub/pubsub.spec.js +1 -1
- package/src/core/pubsub/pubsub.test.js +12 -0
- package/src/core/q/q.html +18 -0
- package/src/core/q/q.js +33 -0
- package/src/core/q/q.test.js +0 -0
- package/src/core/root-element.spec.js +4 -4
- package/src/core/sanitize/sanitize-uri.spec.js +1 -1
- package/src/core/sanitize/sanitize-uri.test.js +12 -0
- package/src/core/sanitize/sanitize.html +21 -0
- package/src/core/sce/sce.html +18 -0
- package/src/core/sce/sce.spec.js +2 -1
- package/src/core/sce/sce.test.js +12 -0
- package/src/core/scope/scope.html +18 -0
- package/src/core/scope/scope.js +5 -8
- package/src/core/scope/scope.spec.js +1 -1
- package/src/core/scope/scope.test.js +12 -0
- package/src/core/task-tracker-factory.js +9 -11
- package/src/core/timeout/timeout.html +18 -0
- package/src/core/timeout/timeout.js +9 -0
- package/src/core/timeout/timeout.spec.js +2 -2
- package/src/core/timeout/timout.test.js +12 -0
- package/src/core/url-utils/url-utils.html +18 -0
- package/src/core/url-utils/url-utils.spec.js +4 -2
- package/src/core/url-utils/url-utils.test.js +12 -0
- package/src/directive/attrs/attrs.spec.js +1 -2
- package/src/directive/attrs/boolean.spec.js +1 -2
- package/src/directive/attrs/element-style.spec.js +6 -7
- package/src/directive/attrs/src.spec.js +1 -2
- package/src/directive/bind/bind.spec.js +1 -2
- package/src/directive/class/class.spec.js +15 -16
- package/src/directive/cloak/cloak.spec.js +3 -4
- package/src/directive/controller/controller.spec.js +4 -5
- package/src/directive/events/click.spec.js +1 -2
- package/src/directive/events/event.spec.js +1 -1
- package/src/directive/events/events.js +7 -0
- package/src/directive/form/form.spec.js +17 -17
- package/src/directive/if/if.spec.js +2 -2
- package/src/directive/include/include.js +2 -2
- package/src/directive/include/include.spec.js +32 -32
- package/src/directive/init/init.spec.js +2 -3
- package/src/directive/input/input.spec.js +3 -3
- package/src/directive/list/list.spec.js +1 -2
- package/src/directive/model/model.js +13 -0
- package/src/directive/model/model.spec.js +4 -5
- package/src/directive/model-options/model-options.spec.js +3 -3
- package/src/directive/non-bindable/non-bindable.spec.js +1 -2
- package/src/directive/options/options.js +5 -5
- package/src/directive/options/options.spec.js +13 -13
- package/src/directive/ref/href.spec.js +1 -2
- package/src/directive/repeat/repeat.spec.js +12 -12
- package/src/directive/script/script.spec.js +2 -3
- package/src/directive/select/select.js +6 -6
- package/src/directive/select/select.spec.js +5 -5
- package/src/directive/show-hide/show-hide.spec.js +12 -13
- package/src/directive/style/style.spec.js +3 -4
- package/src/directive/switch/switch.spec.js +2 -3
- package/src/directive/validators/validators.spec.js +1 -1
- package/src/exts/aria/aria.spec.js +1 -2
- package/src/exts/messages/messages.spec.js +5 -5
- package/src/filters/filter.spec.js +5 -5
- package/src/filters/filters.html +21 -0
- package/src/filters/filters.spec.js +3 -3
- package/src/filters/filters.test.js +12 -0
- package/src/filters/limit-to.md +1 -1
- package/src/filters/limit-to.spec.js +4 -4
- package/src/filters/order-by.spec.js +2 -2
- package/src/index.js +462 -1
- package/src/loader.js +62 -17
- package/src/public.js +6 -2
- package/src/router/directives/state-directives.spec.js +90 -90
- package/src/router/directives/view-directive.js +2 -2
- package/src/router/directives/view-directive.spec.js +9 -9
- package/src/router/state/state.spec.js +2 -4
- package/src/router/template-factory.spec.js +2 -2
- package/src/router/transition/hook-registry.js +2 -2
- package/src/router/view/view.spec.js +1 -1
- package/src/services/browser.js +56 -39
- package/src/services/document.js +16 -13
- package/src/services/log.js +39 -43
- package/src/services/template-request.js +9 -0
- package/src/shared/common.js +0 -3
- package/src/shared/jqlite/jqlite.js +83 -89
- package/src/shared/jqlite/jqlite.spec.js +218 -222
- package/src/shared/strings.js +2 -2
- package/src/shared/test-utils.js +2 -2
- package/src/shared/utils.js +8 -11
- package/src/src.test.js +10 -0
- package/tsconfig.json +1 -1
- package/tsconfig.types.json +11 -0
- package/types/animations/animate-cache.d.ts +7 -7
- package/types/animations/animate-children-directive.d.ts +3 -6
- package/types/animations/animate-swap.d.ts +7 -16
- package/types/animations/animation.d.ts +2 -11
- package/types/animations/raf-scheduler.d.ts +3 -3
- package/types/animations/shared.d.ts +9 -24
- package/types/core/{animate-css.d.ts → animate/animate-css.d.ts} +2 -8
- package/types/core/{cache.d.ts → cache/cache.d.ts} +5 -5
- package/types/core/compile/compile.d.ts +173 -0
- package/types/core/controller/controller.d.ts +32 -0
- package/types/core/exception-handler.d.ts +9 -42
- package/types/core/filter/filter.d.ts +9 -0
- package/types/core/{interpolate.d.ts → interpolate/interpolate.d.ts} +23 -39
- package/types/core/interval/interval-factory.d.ts +4 -0
- package/types/core/{interval.d.ts → interval/interval.d.ts} +1 -1
- package/types/core/location/location.d.ts +209 -0
- package/types/core/pubsub/pubsub.d.ts +156 -0
- package/types/core/q/q.d.ts +65 -0
- package/types/core/sanitize/sanitize-uri.d.ts +53 -0
- package/types/core/{sce.d.ts → sce/sce.d.ts} +80 -86
- package/types/core/scope/scope.d.ts +727 -0
- package/types/core/task-tracker-factory.d.ts +45 -38
- package/types/core/timeout/timeout.d.ts +29 -0
- package/types/core/{urlUtils.d.ts → url-utils/url-utils.d.ts} +2 -7
- package/types/directive/{bind.d.ts → bind/bind.d.ts} +4 -10
- package/types/directive/{class.d.ts → class/class.d.ts} +12 -21
- package/types/directive/controller/controller.d.ts +6 -0
- package/types/directive/events/events.d.ts +5 -0
- package/types/directive/form/form.d.ts +200 -0
- package/types/directive/if/if.d.ts +8 -0
- package/types/directive/include/include.d.ts +14 -0
- package/types/directive/{input.d.ts → input/input.d.ts} +20 -69
- package/types/directive/{model.d.ts → model/model.d.ts} +281 -280
- package/types/directive/options/options.d.ts +9 -0
- package/types/directive/ref/ref.d.ts +5 -0
- package/types/directive/repeat/repeat.d.ts +8 -0
- package/types/directive/{script.d.ts → script/script.d.ts} +5 -8
- package/types/directive/{show-hide.d.ts → show-hide/show-hide.d.ts} +10 -16
- package/types/directive/switch/switch.d.ts +17 -0
- package/types/directive/transclude/transclude.d.ts +4 -0
- package/types/directive/{validators.d.ts → validators/validators.d.ts} +20 -35
- package/types/filters/filters.d.ts +10 -16
- package/types/filters/order-by.d.ts +2 -4
- package/types/index.d.ts +702 -0
- package/types/injector.d.ts +12 -0
- package/types/public.d.ts +5 -0
- package/types/router/common/coreservices.d.ts +2 -2
- package/types/router/common/glob.d.ts +9 -9
- package/types/router/common/queue.d.ts +13 -13
- package/types/router/common/trace.d.ts +43 -43
- package/types/router/directives/view-directive.d.ts +13 -32
- package/types/router/globals.d.ts +20 -20
- package/types/router/hooks/lazy-load.d.ts +2 -11
- package/types/router/hooks/redirect-to.d.ts +1 -4
- package/types/router/hooks/url.d.ts +1 -5
- package/types/router/hooks/views.d.ts +1 -4
- package/types/router/params/param-factory.d.ts +5 -5
- package/types/router/params/param-type.d.ts +35 -35
- package/types/router/params/param-types.d.ts +11 -11
- package/types/router/params/param.d.ts +38 -38
- package/types/router/params/state-params.d.ts +10 -10
- package/types/router/path/path-node.d.ts +34 -34
- package/types/router/path/path-utils.d.ts +73 -77
- package/types/router/resolve/resolvable.d.ts +32 -32
- package/types/router/resolve/resolve-context.d.ts +84 -84
- package/types/router/services.d.ts +4 -9
- package/types/router/state/state-builder.d.ts +27 -27
- package/types/router/state/state-matcher.d.ts +5 -5
- package/types/router/state/state-object.d.ts +58 -58
- package/types/router/state/state-queue-manager.d.ts +10 -16
- package/types/router/state/state-registry.d.ts +100 -107
- package/types/router/state/state-service.d.ts +411 -411
- package/types/router/state/target-state.d.ts +64 -69
- package/types/router/state/views.d.ts +31 -37
- package/types/router/state-filters.d.ts +7 -7
- package/types/router/state-provider.d.ts +105 -105
- package/types/router/template-factory.d.ts +83 -112
- package/types/router/transition/hook-builder.d.ts +25 -25
- package/types/router/transition/hook-registry.d.ts +68 -83
- package/types/router/transition/interface.d.ts +7 -7
- package/types/router/transition/reject-factory.d.ts +34 -34
- package/types/router/transition/transition-event-type.d.ts +9 -18
- package/types/router/transition/transition-hook.d.ts +77 -82
- package/types/router/transition/transition-service.d.ts +82 -99
- package/types/router/transition/transition.d.ts +369 -377
- package/types/router/url/url-config.d.ts +84 -84
- package/types/router/url/url-matcher.d.ts +115 -119
- package/types/router/url/url-rule.d.ts +114 -124
- package/types/router/url/url-rules.d.ts +217 -217
- package/types/router/url/url-service.d.ts +264 -269
- package/types/router/view/view.d.ts +114 -117
- package/types/router/view-scroll.d.ts +2 -2
- package/types/services/anchor-scroll.d.ts +2 -8
- package/types/services/browser.d.ts +157 -135
- package/types/services/cache-factory.d.ts +25 -25
- package/types/services/cookie-reader.d.ts +2 -2
- package/types/services/document.d.ts +13 -9
- package/types/services/http/http.d.ts +145 -0
- package/types/services/{http-backend.d.ts → http-backend/http-backend.d.ts} +3 -35
- package/types/services/log.d.ts +55 -52
- package/types/services/template-request.d.ts +44 -53
- package/types/shared/common.d.ts +4 -20
- package/types/{constants.d.ts → shared/constants.d.ts} +6 -6
- package/types/shared/hof.d.ts +1 -1
- package/types/{jqLite.d.ts → shared/jqlite/jqlite.d.ts} +16 -17
- package/types/shared/test-utils.d.ts +11 -0
- package/types/shared/utils.d.ts +29 -46
- package/types-back/global.d.ts +3 -1
- package/types-back/index.d.ts +3 -296
- package/types/core/compile.d.ts +0 -206
- package/types/core/controller.d.ts +0 -42
- package/types/core/filter.d.ts +0 -9
- package/types/core/interval-factory.d.ts +0 -21
- package/types/core/location.d.ts +0 -234
- package/types/core/pubsub.d.ts +0 -164
- package/types/core/q.d.ts +0 -33
- package/types/core/root-scope.d.ts +0 -754
- package/types/core/sanitize-uri.d.ts +0 -57
- package/types/core/timeout.d.ts +0 -31
- package/types/directive/controller.d.ts +0 -6
- package/types/directive/events.d.ts +0 -12
- package/types/directive/form.d.ts +0 -230
- package/types/directive/if.d.ts +0 -17
- package/types/directive/include.d.ts +0 -33
- package/types/directive/options.d.ts +0 -16
- package/types/directive/ref.d.ts +0 -11
- package/types/directive/repeat.d.ts +0 -23
- package/types/directive/switch.d.ts +0 -23
- package/types/directive/transclude.d.ts +0 -15
- package/types/services/http.d.ts +0 -157
- /package/src/core/cache/{cache-factor.spec.js → cache-factory.spec.js} +0 -0
- /package/types/directive/{attrs.d.ts → attrs/attrs.d.ts} +0 -0
- /package/types/directive/{change.d.ts → change/change.d.ts} +0 -0
- /package/types/directive/{cloak.d.ts → cloak/cloak.d.ts} +0 -0
- /package/types/directive/{init.d.ts → init/init.d.ts} +0 -0
- /package/types/directive/{list.d.ts → list/list.d.ts} +0 -0
- /package/types/directive/{non-bindable.d.ts → non-bindable/non-bindable.d.ts} +0 -0
- /package/types/directive/{style.d.ts → style/style.d.ts} +0 -0
- /package/types/exts/{aria.d.ts → aria/aria.d.ts} +0 -0
- /package/types/exts/{messages.d.ts → messages/messages.d.ts} +0 -0
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
import { CACHE, EXPANDO } from "../../core/cache/cache";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* @ngdoc function
|
|
21
20
|
* @name angular.element
|
|
22
21
|
* @module ng
|
|
23
22
|
* @kind function
|
|
@@ -26,24 +25,23 @@ import { CACHE, EXPANDO } from "../../core/cache/cache";
|
|
|
26
25
|
* Wraps a raw DOM element or HTML string as a [jQuery](http://jquery.com) element. Regardless of the presence of jQuery, `angular.element`
|
|
27
26
|
* delegates to AngularJS's built-in subset of jQuery, called "jQuery lite" or **jqLite**.
|
|
28
27
|
*
|
|
29
|
-
*
|
|
30
|
-
* AngularJS to manipulate the DOM in a cross-browser compatible way.
|
|
28
|
+
* JQLite is a tiny, API-compatible subset of jQuery that allows
|
|
29
|
+
* AngularJS to manipulate the DOM in a cross-browser compatible way. JQLite implements only the most
|
|
31
30
|
* commonly needed functionality with the goal of having a very small footprint.
|
|
32
31
|
*
|
|
33
|
-
*
|
|
34
32
|
* <div class="alert alert-info">**Note:** All element references in AngularJS are always wrapped with
|
|
35
|
-
*
|
|
33
|
+
* JQLite (such as the element argument in a directive's compile / link function). They are never raw DOM references.</div>
|
|
36
34
|
*
|
|
37
35
|
* <div class="alert alert-warning">**Note:** Keep in mind that this function will not find elements
|
|
38
36
|
* by tag name / CSS selector. For lookups by tag name, try instead `angular.element(document).find(...)`
|
|
39
37
|
* or `$document.find()`, or use the standard DOM APIs, e.g. `document.querySelectorAll()`.</div>
|
|
40
38
|
*
|
|
41
|
-
* ## AngularJS's
|
|
42
|
-
*
|
|
39
|
+
* ## AngularJS's JQLite
|
|
40
|
+
* JQLite provides only the following jQuery methods:
|
|
43
41
|
*
|
|
44
42
|
* - [`after()`](http://api.jquery.com/after/)
|
|
45
43
|
* - [`append()`](http://api.jquery.com/append/) - Contrary to jQuery, this doesn't clone elements
|
|
46
|
-
* so will not work correctly when invoked on a
|
|
44
|
+
* so will not work correctly when invoked on a JQLite object containing more than one DOM node
|
|
47
45
|
* - [`attr()`](http://api.jquery.com/attr/) - Does not support functions as parameters
|
|
48
46
|
* - [`children()`](http://api.jquery.com/children/) - Does not support selectors
|
|
49
47
|
* - [`data()`](http://api.jquery.com/data/)
|
|
@@ -63,10 +61,10 @@ import { CACHE, EXPANDO } from "../../core/cache/cache";
|
|
|
63
61
|
* - [`val()`](http://api.jquery.com/val/)
|
|
64
62
|
*
|
|
65
63
|
* ## jQuery/jqLite Extras
|
|
66
|
-
* AngularJS also provides the following additional methods and events to both jQuery and
|
|
64
|
+
* AngularJS also provides the following additional methods and events to both jQuery and JQLite:
|
|
67
65
|
*
|
|
68
66
|
* ### Events
|
|
69
|
-
* - `$destroy` - AngularJS intercepts all
|
|
67
|
+
* - `$destroy` - AngularJS intercepts all JQLite/jQuery's DOM destruction apis and fires this event
|
|
70
68
|
* on all DOM nodes being removed. This can be used to clean up any 3rd party bindings to the DOM
|
|
71
69
|
* element before it is removed.
|
|
72
70
|
*
|
|
@@ -93,6 +91,7 @@ import { CACHE, EXPANDO } from "../../core/cache/cache";
|
|
|
93
91
|
* @returns {Object} jQuery object.
|
|
94
92
|
*/
|
|
95
93
|
|
|
94
|
+
/** @type {number} */
|
|
96
95
|
let jqId = 1;
|
|
97
96
|
|
|
98
97
|
function jqNextId() {
|
|
@@ -102,7 +101,7 @@ function jqNextId() {
|
|
|
102
101
|
const DASH_LOWERCASE_REGEXP = /-([a-z])/g;
|
|
103
102
|
const UNDERSCORE_LOWERCASE_REGEXP = /_([a-z])/g;
|
|
104
103
|
const MOUSE_EVENT_MAP = { mouseleave: "mouseout", mouseenter: "mouseover" };
|
|
105
|
-
const
|
|
104
|
+
const JQLiteMinErr = minErr("jqLite");
|
|
106
105
|
|
|
107
106
|
/**
|
|
108
107
|
* @param {string} _all
|
|
@@ -180,7 +179,7 @@ function elementAcceptsData(node) {
|
|
|
180
179
|
}
|
|
181
180
|
}
|
|
182
181
|
|
|
183
|
-
export function
|
|
182
|
+
export function JQLiteBuildFragment(html, context) {
|
|
184
183
|
let tmp;
|
|
185
184
|
let tag;
|
|
186
185
|
let wrap;
|
|
@@ -225,7 +224,7 @@ export function jqLiteBuildFragment(html, context) {
|
|
|
225
224
|
return fragment;
|
|
226
225
|
}
|
|
227
226
|
|
|
228
|
-
function
|
|
227
|
+
function JQLiteParseHTML(html, context) {
|
|
229
228
|
context = context || window.document;
|
|
230
229
|
let parsed;
|
|
231
230
|
|
|
@@ -233,20 +232,13 @@ function jqLiteParseHTML(html, context) {
|
|
|
233
232
|
return [context.createElement(parsed[1])];
|
|
234
233
|
}
|
|
235
234
|
|
|
236
|
-
if ((parsed =
|
|
235
|
+
if ((parsed = JQLiteBuildFragment(html, context))) {
|
|
237
236
|
return parsed.childNodes;
|
|
238
237
|
}
|
|
239
238
|
|
|
240
239
|
return [];
|
|
241
240
|
}
|
|
242
241
|
|
|
243
|
-
// IE9-11 has no method "contains" in SVG element and in Node.prototype. Bug #10259.
|
|
244
|
-
const jqLiteContains =
|
|
245
|
-
window.Node.prototype.contains ||
|
|
246
|
-
function (arg) {
|
|
247
|
-
return !!(this.compareDocumentPosition(arg) & 16);
|
|
248
|
-
};
|
|
249
|
-
|
|
250
242
|
/// //////////////////////////////////////////
|
|
251
243
|
export function JQLite(element) {
|
|
252
244
|
if (element instanceof JQLite) {
|
|
@@ -261,26 +253,23 @@ export function JQLite(element) {
|
|
|
261
253
|
}
|
|
262
254
|
if (!(this instanceof JQLite)) {
|
|
263
255
|
if (argIsString && element.charAt(0) !== "<") {
|
|
264
|
-
throw
|
|
256
|
+
throw JQLiteMinErr(
|
|
265
257
|
"nosel",
|
|
266
|
-
"Looking up elements via selectors is not supported by
|
|
258
|
+
"Looking up elements via selectors is not supported by JQLite! See: http://docs.angularjs.org/api/angular.element",
|
|
267
259
|
);
|
|
268
260
|
}
|
|
269
261
|
return new JQLite(element);
|
|
270
262
|
}
|
|
271
263
|
|
|
272
264
|
if (argIsString) {
|
|
273
|
-
const parsed =
|
|
265
|
+
const parsed = JQLiteParseHTML(element);
|
|
274
266
|
addNodes(this, parsed);
|
|
275
267
|
} else if (isFunction(element)) {
|
|
276
|
-
|
|
268
|
+
JQLiteReady(element);
|
|
277
269
|
} else {
|
|
278
270
|
addNodes(this, element);
|
|
279
271
|
}
|
|
280
272
|
}
|
|
281
|
-
export var jqLite = JQLite;
|
|
282
|
-
|
|
283
|
-
jqLite.CACHE = CACHE;
|
|
284
273
|
|
|
285
274
|
/**
|
|
286
275
|
* @param {Element} element
|
|
@@ -290,10 +279,10 @@ jqLite.CACHE = CACHE;
|
|
|
290
279
|
export function dealoc(element, onlyDescendants) {
|
|
291
280
|
if (!element) return;
|
|
292
281
|
if (!onlyDescendants && elementAcceptsData(element))
|
|
293
|
-
|
|
282
|
+
JQLiteCleanData([element]);
|
|
294
283
|
|
|
295
284
|
if (element.querySelectorAll) {
|
|
296
|
-
|
|
285
|
+
JQLiteCleanData(element.querySelectorAll("*"));
|
|
297
286
|
}
|
|
298
287
|
}
|
|
299
288
|
|
|
@@ -316,14 +305,14 @@ function removeIfEmptyData(element) {
|
|
|
316
305
|
}
|
|
317
306
|
}
|
|
318
307
|
|
|
319
|
-
function
|
|
308
|
+
function JQLiteOff(element, type, fn, unsupported) {
|
|
320
309
|
if (isDefined(unsupported))
|
|
321
|
-
throw
|
|
310
|
+
throw JQLiteMinErr(
|
|
322
311
|
"offargs",
|
|
323
312
|
"jqLite#off() does not support the `selector` argument",
|
|
324
313
|
);
|
|
325
314
|
|
|
326
|
-
const expandoStore =
|
|
315
|
+
const expandoStore = JQLiteExpandoStore(element);
|
|
327
316
|
const events = expandoStore && expandoStore.events;
|
|
328
317
|
const handle = expandoStore && expandoStore.handle;
|
|
329
318
|
|
|
@@ -366,7 +355,7 @@ function jqLiteOff(element, type, fn, unsupported) {
|
|
|
366
355
|
* @param {Element} element
|
|
367
356
|
* @param {string} [name] - key of field to remove
|
|
368
357
|
*/
|
|
369
|
-
function
|
|
358
|
+
function JQLiteRemoveData(element, name) {
|
|
370
359
|
const expandoId = element[EXPANDO];
|
|
371
360
|
const expandoStore = expandoId && CACHE.get(expandoId);
|
|
372
361
|
|
|
@@ -382,12 +371,15 @@ function jqLiteRemoveData(element, name) {
|
|
|
382
371
|
}
|
|
383
372
|
|
|
384
373
|
/**
|
|
374
|
+
* Stores data associated with an element inside the expando property of the DOM element.
|
|
375
|
+
*
|
|
376
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Expando MDN Glossary: Expando}
|
|
385
377
|
*
|
|
386
378
|
* @param {Element} element
|
|
387
|
-
* @param {boolean} createIfNecessary
|
|
388
|
-
* @returns {import("
|
|
379
|
+
* @param {boolean} [createIfNecessary=false]
|
|
380
|
+
* @returns {import("../../core/cache/cache").ExpandoStore}
|
|
389
381
|
*/
|
|
390
|
-
function
|
|
382
|
+
function JQLiteExpandoStore(element, createIfNecessary = false) {
|
|
391
383
|
let expandoId = element[EXPANDO];
|
|
392
384
|
let expandoStore = expandoId && CACHE.get(expandoId);
|
|
393
385
|
|
|
@@ -404,14 +396,14 @@ function jqLiteExpandoStore(element, createIfNecessary = false) {
|
|
|
404
396
|
return expandoStore;
|
|
405
397
|
}
|
|
406
398
|
|
|
407
|
-
function
|
|
399
|
+
function JQLiteData(element, key, value) {
|
|
408
400
|
if (elementAcceptsData(element)) {
|
|
409
401
|
let prop;
|
|
410
402
|
|
|
411
403
|
const isSimpleSetter = isDefined(value);
|
|
412
404
|
const isSimpleGetter = !isSimpleSetter && key && !isObject(key);
|
|
413
405
|
const massGetter = !key;
|
|
414
|
-
const expandoStore =
|
|
406
|
+
const expandoStore = JQLiteExpandoStore(element, !isSimpleGetter);
|
|
415
407
|
const data = expandoStore && expandoStore.data;
|
|
416
408
|
|
|
417
409
|
if (isSimpleSetter) {
|
|
@@ -462,11 +454,11 @@ function addNodes(root, elements) {
|
|
|
462
454
|
}
|
|
463
455
|
}
|
|
464
456
|
|
|
465
|
-
function
|
|
466
|
-
return
|
|
457
|
+
function JQLiteController(element, name) {
|
|
458
|
+
return JQLiteInheritedData(element, `$${name || "ngController"}Controller`);
|
|
467
459
|
}
|
|
468
460
|
|
|
469
|
-
function
|
|
461
|
+
function JQLiteInheritedData(element, name, value) {
|
|
470
462
|
// if element is the document object work with the html element instead
|
|
471
463
|
// this makes $(document).scope() possible
|
|
472
464
|
if (element.nodeType === Node.DOCUMENT_NODE) {
|
|
@@ -476,7 +468,7 @@ function jqLiteInheritedData(element, name, value) {
|
|
|
476
468
|
|
|
477
469
|
while (element) {
|
|
478
470
|
for (let i = 0, ii = names.length; i < ii; i++) {
|
|
479
|
-
if (isDefined((value =
|
|
471
|
+
if (isDefined((value = JQLiteData(element, names[i])))) return value;
|
|
480
472
|
}
|
|
481
473
|
|
|
482
474
|
// If dealing with a document fragment node with a host element, and no parent, use the host
|
|
@@ -488,20 +480,20 @@ function jqLiteInheritedData(element, name, value) {
|
|
|
488
480
|
}
|
|
489
481
|
}
|
|
490
482
|
|
|
491
|
-
function
|
|
483
|
+
function JQLiteEmpty(element) {
|
|
492
484
|
dealoc(element, true);
|
|
493
485
|
while (element.firstChild) {
|
|
494
486
|
element.removeChild(element.firstChild);
|
|
495
487
|
}
|
|
496
488
|
}
|
|
497
489
|
|
|
498
|
-
export function
|
|
490
|
+
export function JQLiteRemove(element, keepData) {
|
|
499
491
|
if (!keepData) dealoc(element);
|
|
500
492
|
const parent = element.parentNode;
|
|
501
493
|
if (parent) parent.removeChild(element);
|
|
502
494
|
}
|
|
503
495
|
|
|
504
|
-
function
|
|
496
|
+
function JQLiteReady(fn) {
|
|
505
497
|
function trigger() {
|
|
506
498
|
window.document.removeEventListener("DOMContentLoaded", trigger);
|
|
507
499
|
window.removeEventListener("load", trigger);
|
|
@@ -512,7 +504,7 @@ function jqLiteReady(fn) {
|
|
|
512
504
|
if (window.document.readyState === "complete") {
|
|
513
505
|
window.setTimeout(fn);
|
|
514
506
|
} else {
|
|
515
|
-
// We can not use
|
|
507
|
+
// We can not use JQLite since we are not done loading and jQuery could be loaded later.
|
|
516
508
|
|
|
517
509
|
// Works for modern browsers and IE9
|
|
518
510
|
window.document.addEventListener("DOMContentLoaded", trigger);
|
|
@@ -526,7 +518,7 @@ function jqLiteReady(fn) {
|
|
|
526
518
|
// Functions which are declared directly.
|
|
527
519
|
/// ///////////////////////////////////////
|
|
528
520
|
JQLite.prototype = {
|
|
529
|
-
ready:
|
|
521
|
+
ready: JQLiteReady,
|
|
530
522
|
toString() {
|
|
531
523
|
const value = [];
|
|
532
524
|
forEach(this, (e) => {
|
|
@@ -536,7 +528,7 @@ JQLite.prototype = {
|
|
|
536
528
|
},
|
|
537
529
|
|
|
538
530
|
eq(index) {
|
|
539
|
-
return index >= 0 ?
|
|
531
|
+
return index >= 0 ? JQLite(this[index]) : JQLite(this[this.length + index]);
|
|
540
532
|
},
|
|
541
533
|
|
|
542
534
|
length: 0,
|
|
@@ -571,22 +563,22 @@ export function getBooleanAttrName(element, name) {
|
|
|
571
563
|
return booleanAttr && BOOLEAN_ELEMENTS[nodeName_(element)] && booleanAttr;
|
|
572
564
|
}
|
|
573
565
|
|
|
574
|
-
export function
|
|
566
|
+
export function JQLiteCleanData(nodes) {
|
|
575
567
|
for (let i = 0, ii = nodes.length; i < ii; i++) {
|
|
576
568
|
var events = (CACHE.get(nodes[i][EXPANDO]) || {}).events;
|
|
577
569
|
if (events && events.$destroy) {
|
|
578
|
-
|
|
570
|
+
JQLite(nodes[i]).triggerHandler("$destroy");
|
|
579
571
|
}
|
|
580
|
-
|
|
581
|
-
|
|
572
|
+
JQLiteRemoveData(nodes[i]);
|
|
573
|
+
JQLiteOff(nodes[i]);
|
|
582
574
|
}
|
|
583
575
|
}
|
|
584
576
|
|
|
585
577
|
forEach(
|
|
586
578
|
{
|
|
587
|
-
data:
|
|
588
|
-
removeData:
|
|
589
|
-
cleanData:
|
|
579
|
+
data: JQLiteData,
|
|
580
|
+
removeData: JQLiteRemoveData,
|
|
581
|
+
cleanData: JQLiteCleanData,
|
|
590
582
|
},
|
|
591
583
|
(fn, name) => {
|
|
592
584
|
JQLite[name] = fn;
|
|
@@ -595,14 +587,14 @@ forEach(
|
|
|
595
587
|
|
|
596
588
|
forEach(
|
|
597
589
|
{
|
|
598
|
-
data:
|
|
599
|
-
inheritedData:
|
|
590
|
+
data: JQLiteData,
|
|
591
|
+
inheritedData: JQLiteInheritedData,
|
|
600
592
|
|
|
601
593
|
scope(element) {
|
|
602
|
-
// Can't use
|
|
594
|
+
// Can't use JQLiteData here directly so we stay compatible with jQuery!
|
|
603
595
|
return (
|
|
604
|
-
|
|
605
|
-
|
|
596
|
+
JQLiteData(element, "$scope") ||
|
|
597
|
+
JQLiteInheritedData(element.parentNode || element, [
|
|
606
598
|
"$isolateScope",
|
|
607
599
|
"$scope",
|
|
608
600
|
])
|
|
@@ -610,17 +602,17 @@ forEach(
|
|
|
610
602
|
},
|
|
611
603
|
|
|
612
604
|
isolateScope(element) {
|
|
613
|
-
// Can't use
|
|
605
|
+
// Can't use JQLiteData here directly so we stay compatible with jQuery!
|
|
614
606
|
return (
|
|
615
|
-
|
|
616
|
-
|
|
607
|
+
JQLiteData(element, "$isolateScope") ||
|
|
608
|
+
JQLiteData(element, "$isolateScopeNoTemplate")
|
|
617
609
|
);
|
|
618
610
|
},
|
|
619
611
|
|
|
620
|
-
controller:
|
|
612
|
+
controller: JQLiteController,
|
|
621
613
|
|
|
622
614
|
injector(element) {
|
|
623
|
-
return
|
|
615
|
+
return JQLiteInheritedData(element, "$injector");
|
|
624
616
|
},
|
|
625
617
|
|
|
626
618
|
attr(element, name, value) {
|
|
@@ -697,7 +689,7 @@ forEach(
|
|
|
697
689
|
element.innerHTML = value;
|
|
698
690
|
},
|
|
699
691
|
|
|
700
|
-
empty:
|
|
692
|
+
empty: JQLiteEmpty,
|
|
701
693
|
},
|
|
702
694
|
(fn, name) => {
|
|
703
695
|
/**
|
|
@@ -708,15 +700,15 @@ forEach(
|
|
|
708
700
|
let key;
|
|
709
701
|
const nodeCount = this.length;
|
|
710
702
|
|
|
711
|
-
//
|
|
703
|
+
// JQLiteEmpty takes no arguments but is a setter.
|
|
712
704
|
if (
|
|
713
|
-
fn !==
|
|
714
|
-
isUndefined(fn.length === 2 && fn !==
|
|
705
|
+
fn !== JQLiteEmpty &&
|
|
706
|
+
isUndefined(fn.length === 2 && fn !== JQLiteController ? arg1 : arg2)
|
|
715
707
|
) {
|
|
716
708
|
if (isObject(arg1)) {
|
|
717
709
|
// we are a write, but the object properties are the key/values
|
|
718
710
|
for (i = 0; i < nodeCount; i++) {
|
|
719
|
-
if (fn ===
|
|
711
|
+
if (fn === JQLiteData) {
|
|
720
712
|
fn(this[i], arg1);
|
|
721
713
|
} else {
|
|
722
714
|
for (key in arg1) {
|
|
@@ -805,6 +797,11 @@ function defaultHandlerWrapper(element, event, handler) {
|
|
|
805
797
|
handler.call(element, event);
|
|
806
798
|
}
|
|
807
799
|
|
|
800
|
+
/**
|
|
801
|
+
* @param {Node} target
|
|
802
|
+
* @param {*} event
|
|
803
|
+
* @param {*} handler
|
|
804
|
+
*/
|
|
808
805
|
function specialMouseHandlerWrapper(target, event, handler) {
|
|
809
806
|
// Refer to jQuery's implementation of mouseenter & mouseleave
|
|
810
807
|
// Read about mouseenter and mouseleave:
|
|
@@ -812,10 +809,7 @@ function specialMouseHandlerWrapper(target, event, handler) {
|
|
|
812
809
|
const related = event.relatedTarget;
|
|
813
810
|
// For mousenter/leave call the handler if related is outside the target.
|
|
814
811
|
// NB: No relatedTarget if the mouse left/entered the browser window
|
|
815
|
-
if (
|
|
816
|
-
!related ||
|
|
817
|
-
(related !== target && !jqLiteContains.call(target, related))
|
|
818
|
-
) {
|
|
812
|
+
if (!related || (related !== target && !target.contains(related))) {
|
|
819
813
|
handler.call(target, event);
|
|
820
814
|
}
|
|
821
815
|
}
|
|
@@ -827,10 +821,10 @@ function specialMouseHandlerWrapper(target, event, handler) {
|
|
|
827
821
|
/// ///////////////////////////////////////
|
|
828
822
|
forEach(
|
|
829
823
|
{
|
|
830
|
-
removeData:
|
|
824
|
+
removeData: JQLiteRemoveData,
|
|
831
825
|
on: (element, type, fn, unsupported) => {
|
|
832
826
|
if (isDefined(unsupported))
|
|
833
|
-
throw
|
|
827
|
+
throw JQLiteMinErr(
|
|
834
828
|
"onargs",
|
|
835
829
|
"jqLite#on() does not support the `selector` or `eventData` parameters",
|
|
836
830
|
);
|
|
@@ -840,7 +834,7 @@ forEach(
|
|
|
840
834
|
return;
|
|
841
835
|
}
|
|
842
836
|
|
|
843
|
-
const expandoStore =
|
|
837
|
+
const expandoStore = JQLiteExpandoStore(element, true);
|
|
844
838
|
const { events } = expandoStore;
|
|
845
839
|
let { handle } = expandoStore;
|
|
846
840
|
|
|
@@ -881,7 +875,7 @@ forEach(
|
|
|
881
875
|
}
|
|
882
876
|
},
|
|
883
877
|
|
|
884
|
-
off:
|
|
878
|
+
off: JQLiteOff,
|
|
885
879
|
|
|
886
880
|
replaceWith(element, replaceNode) {
|
|
887
881
|
let index;
|
|
@@ -928,10 +922,10 @@ forEach(
|
|
|
928
922
|
}
|
|
929
923
|
},
|
|
930
924
|
|
|
931
|
-
remove:
|
|
925
|
+
remove: JQLiteRemove,
|
|
932
926
|
|
|
933
927
|
detach(element) {
|
|
934
|
-
|
|
928
|
+
JQLiteRemove(element, true);
|
|
935
929
|
},
|
|
936
930
|
|
|
937
931
|
after(element, newElement) {
|
|
@@ -956,7 +950,7 @@ forEach(
|
|
|
956
950
|
: null;
|
|
957
951
|
},
|
|
958
952
|
|
|
959
|
-
// TODO: remove after migrating tests away from
|
|
953
|
+
// TODO: remove after migrating tests away from JQLite
|
|
960
954
|
find(element, selector) {
|
|
961
955
|
if (element.getElementsByTagName) {
|
|
962
956
|
return element.getElementsByTagName(selector);
|
|
@@ -969,7 +963,7 @@ forEach(
|
|
|
969
963
|
let eventFnsCopy;
|
|
970
964
|
let handlerArgs;
|
|
971
965
|
const eventName = event.type || event;
|
|
972
|
-
const expandoStore =
|
|
966
|
+
const expandoStore = JQLiteExpandoStore(element);
|
|
973
967
|
const events = expandoStore && expandoStore.events;
|
|
974
968
|
const eventFns = events && events[eventName];
|
|
975
969
|
|
|
@@ -1024,7 +1018,7 @@ forEach(
|
|
|
1024
1018
|
value = fn(this[i], arg1, arg2, arg3);
|
|
1025
1019
|
if (isDefined(value)) {
|
|
1026
1020
|
// any function which returns a value needs to be wrapped
|
|
1027
|
-
value =
|
|
1021
|
+
value = JQLite(value);
|
|
1028
1022
|
}
|
|
1029
1023
|
} else {
|
|
1030
1024
|
addNodes(value, fn(this[i], arg1, arg2, arg3));
|
|
@@ -1040,9 +1034,9 @@ forEach(
|
|
|
1040
1034
|
* @returns {string} Returns the string representation of the element.
|
|
1041
1035
|
*/
|
|
1042
1036
|
export function startingTag(elementStr) {
|
|
1043
|
-
const clone =
|
|
1044
|
-
const element =
|
|
1045
|
-
var elemHtml =
|
|
1037
|
+
const clone = JQLite(elementStr)[0].cloneNode(true);
|
|
1038
|
+
const element = JQLite(clone).empty();
|
|
1039
|
+
var elemHtml = JQLite("<div></div>").append(element).html();
|
|
1046
1040
|
try {
|
|
1047
1041
|
return element[0].nodeType === Node.TEXT_NODE
|
|
1048
1042
|
? lowercase(elemHtml)
|
|
@@ -1059,7 +1053,7 @@ export function startingTag(elementStr) {
|
|
|
1059
1053
|
/**
|
|
1060
1054
|
* Return the DOM siblings between the first and last node in the given array.
|
|
1061
1055
|
* @param {Array} nodes An array-like object
|
|
1062
|
-
* @returns {Array} the inputted object or a
|
|
1056
|
+
* @returns {Array} the inputted object or a JQLite collection containing the nodes
|
|
1063
1057
|
*/
|
|
1064
1058
|
export function getBlockNodes(nodes) {
|
|
1065
1059
|
// TODO(perf): update `nodes` instead of creating a new object?
|
|
@@ -1071,7 +1065,7 @@ export function getBlockNodes(nodes) {
|
|
|
1071
1065
|
if (blockNodes || nodes[i] !== node) {
|
|
1072
1066
|
if (!blockNodes) {
|
|
1073
1067
|
// use element to avoid circular dependency
|
|
1074
|
-
blockNodes =
|
|
1068
|
+
blockNodes = JQLite(Array.prototype.slice.call(nodes, 0, i));
|
|
1075
1069
|
}
|
|
1076
1070
|
blockNodes.push(node);
|
|
1077
1071
|
}
|