@angular-wave/angular.ts 0.2.2 → 0.2.3
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/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/angular.spec.js +1 -1
- package/src/animations/animate.spec.js +1 -1
- package/src/core/compile/attributes.js +1 -1
- package/src/core/compile/compile.js +10 -6
- package/src/core/compile/compile.spec.js +0 -6
- package/src/core/di/internal-injector.js +14 -14
- package/src/core/di/ng-module.js +2 -2
- package/src/core/filter/filter.md +1 -1
- package/src/core/location/location.spec.js +9 -9
- package/src/core/sanitize/sanitize-uri.spec.js +1 -1
- package/src/core/sce/sce.spec.js +3 -3
- package/src/core/scope/scope.spec.js +1 -1
- package/src/core/url-utils/url-utils.js +4 -4
- package/src/core/url-utils/url-utils.spec.js +1 -1
- package/src/directive/attrs/boolean.spec.js +1 -1
- package/src/directive/class/class.js +10 -90
- package/src/directive/class/class.md +90 -0
- package/src/directive/class/class.spec.js +1 -1
- package/src/directive/controller/controller.spec.js +0 -12
- package/src/directive/form/form.spec.js +3 -3
- package/src/directive/include/include.spec.js +1 -1
- package/src/directive/input/input.js +1 -1
- package/src/directive/model/model.js +50 -42
- package/src/directive/options/options.js +2 -2
- package/src/directive/repeat/repeat.spec.js +4 -4
- package/src/directive/select/select.js +1 -1
- package/src/directive/show-hide/show-hide.spec.js +1 -1
- package/src/directive/style/style.spec.js +1 -1
- package/src/directive/switch/switch.spec.js +1 -1
- package/src/directive/validators/validators.js +2 -2
- package/src/filters/filter.js +2 -3
- package/src/filters/limit-to.js +2 -2
- package/src/services/cookie-reader.js +1 -1
- package/src/services/http/http.js +24 -19
- package/src/shared/common.spec.js +1 -3
- package/src/shared/hof.js +1 -2
- package/src/shared/jqlite/jqlite.js +26 -28
- package/src/shared/jqlite/jqlite.spec.js +10 -10
- package/src/shared/utils.js +6 -11
- package/types/core/di/internal-injector.d.ts +6 -6
- package/types/core/di/ng-module.d.ts +2 -2
- package/types/directive/class/class.d.ts +3 -100
- package/types/directive/model/model.d.ts +6 -3
- package/types/directive/validators/validators.d.ts +2 -2
- package/types/shared/hof.d.ts +0 -1
- package/types/shared/jqlite/jqlite.d.ts +4 -4
- package/types/shared/utils.d.ts +5 -5
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@angular-wave/angular.ts",
|
|
3
3
|
"description": "A modern, optimized and typesafe version of AngularJS",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.3",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/angular-ts.esm.js",
|
|
8
8
|
"browser": "dist/angular-ts.umd.js",
|
package/src/angular.spec.js
CHANGED
|
@@ -1970,7 +1970,7 @@ describe("angular", () => {
|
|
|
1970
1970
|
describe("isElement", () => {
|
|
1971
1971
|
it("should return a boolean value", () => {
|
|
1972
1972
|
const element = $compile("<p>Hello, world!</p>")($rootScope);
|
|
1973
|
-
const body =
|
|
1973
|
+
const body = document.body;
|
|
1974
1974
|
const expected = [
|
|
1975
1975
|
false,
|
|
1976
1976
|
false,
|
|
@@ -6,7 +6,7 @@ import { createInjector } from "../di/injector";
|
|
|
6
6
|
|
|
7
7
|
describe("$animate", () => {
|
|
8
8
|
describe("without animation", () => {
|
|
9
|
-
let dummy =
|
|
9
|
+
let dummy = document.getElementById("dummy");
|
|
10
10
|
let element;
|
|
11
11
|
let $compile;
|
|
12
12
|
let $rootElement;
|
|
@@ -13,7 +13,7 @@ import { ALIASED_ATTR } from "../../shared/constants";
|
|
|
13
13
|
|
|
14
14
|
const $compileMinErr = minErr("$compile");
|
|
15
15
|
const SIMPLE_ATTR_NAME = /^\w/;
|
|
16
|
-
const specialAttrHolder =
|
|
16
|
+
const specialAttrHolder = document.createElement("div");
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @typedef {Object} AttributeLike
|
|
@@ -1679,7 +1679,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
1679
1679
|
} else {
|
|
1680
1680
|
// We have transclusion slots,
|
|
1681
1681
|
// collect them up, compile them and store their transclusion functions
|
|
1682
|
-
$template =
|
|
1682
|
+
$template = document.createDocumentFragment();
|
|
1683
1683
|
|
|
1684
1684
|
const slotMap = Object.create(null);
|
|
1685
1685
|
const filledSlots = Object.create(null);
|
|
@@ -1712,8 +1712,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
1712
1712
|
if (slotName) {
|
|
1713
1713
|
filledSlots[slotName] = true;
|
|
1714
1714
|
slots[slotName] =
|
|
1715
|
-
slots[slotName] ||
|
|
1716
|
-
window.document.createDocumentFragment();
|
|
1715
|
+
slots[slotName] || document.createDocumentFragment();
|
|
1717
1716
|
slots[slotName].appendChild(node);
|
|
1718
1717
|
} else {
|
|
1719
1718
|
$template.appendChild(node);
|
|
@@ -2462,12 +2461,17 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2462
2461
|
}
|
|
2463
2462
|
}
|
|
2464
2463
|
|
|
2464
|
+
/**
|
|
2465
|
+
* @param {string} type
|
|
2466
|
+
* @param {string} template
|
|
2467
|
+
* @returns
|
|
2468
|
+
*/
|
|
2465
2469
|
function wrapTemplate(type, template) {
|
|
2466
|
-
type =
|
|
2470
|
+
type = (type || "html").toLowerCase();
|
|
2467
2471
|
switch (type) {
|
|
2468
2472
|
case "svg":
|
|
2469
2473
|
case "math":
|
|
2470
|
-
var wrapper =
|
|
2474
|
+
var wrapper = document.createElement("div");
|
|
2471
2475
|
wrapper.innerHTML = `<${type}>${template}</${type}>`;
|
|
2472
2476
|
return wrapper.childNodes[0].childNodes;
|
|
2473
2477
|
default:
|
|
@@ -2775,7 +2779,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2775
2779
|
// - remove them from the DOM
|
|
2776
2780
|
// - allow them to still be traversed with .nextSibling
|
|
2777
2781
|
// - allow a single fragment.qSA to fetch all elements being removed
|
|
2778
|
-
const fragment =
|
|
2782
|
+
const fragment = document.createDocumentFragment();
|
|
2779
2783
|
for (i = 0; i < removeCount; i++) {
|
|
2780
2784
|
fragment.appendChild(elementsToRemove[i]);
|
|
2781
2785
|
}
|
|
@@ -25,12 +25,6 @@ function isHTMLElement(el) {
|
|
|
25
25
|
return !!el.toString().match(/HTML/);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function supportsMathML() {
|
|
29
|
-
const d = document.createElement("div");
|
|
30
|
-
d.innerHTML = "<math></math>";
|
|
31
|
-
return !isUnknownElement(d.firstChild);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
28
|
function getChildScopes(scope) {
|
|
35
29
|
let children = [];
|
|
36
30
|
if (!scope.$$childHead) {
|
|
@@ -30,7 +30,7 @@ class AbstractInjector {
|
|
|
30
30
|
/**
|
|
31
31
|
* Get a service by name.
|
|
32
32
|
*
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {string} serviceName
|
|
34
34
|
* @returns {any}
|
|
35
35
|
*/
|
|
36
36
|
get(serviceName) {
|
|
@@ -63,7 +63,7 @@ class AbstractInjector {
|
|
|
63
63
|
*
|
|
64
64
|
* @param {Function|Array} fn
|
|
65
65
|
* @param {Object} locals
|
|
66
|
-
* @param {
|
|
66
|
+
* @param {string} serviceName
|
|
67
67
|
* @returns
|
|
68
68
|
*/
|
|
69
69
|
injectionArgs(fn, locals, serviceName) {
|
|
@@ -94,7 +94,7 @@ class AbstractInjector {
|
|
|
94
94
|
* @param {Function|String|Array<any>} fn
|
|
95
95
|
* @param {*} [self]
|
|
96
96
|
* @param {Object} [locals]
|
|
97
|
-
* @param {
|
|
97
|
+
* @param {string} [serviceName]
|
|
98
98
|
* @returns
|
|
99
99
|
*/
|
|
100
100
|
invoke(fn, self, locals, serviceName) {
|
|
@@ -112,7 +112,7 @@ class AbstractInjector {
|
|
|
112
112
|
fn = fn[fn.length - 1];
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
if (isClass(/** @type {
|
|
115
|
+
if (isClass(/** @type {string} */ (fn))) {
|
|
116
116
|
args.unshift(null);
|
|
117
117
|
return new (Function.prototype.bind.apply(fn, args))();
|
|
118
118
|
} else {
|
|
@@ -124,7 +124,7 @@ class AbstractInjector {
|
|
|
124
124
|
* Instantiate a type constructor with optional locals.
|
|
125
125
|
* @param {Function|Array} type
|
|
126
126
|
* @param {*} [locals]
|
|
127
|
-
* @param {
|
|
127
|
+
* @param {string} [serviceName]
|
|
128
128
|
*/
|
|
129
129
|
instantiate(type, locals, serviceName) {
|
|
130
130
|
// Check if type is annotated and use just the given function at n-1 as parameter
|
|
@@ -143,7 +143,7 @@ class AbstractInjector {
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* @abstract
|
|
146
|
-
* @param {
|
|
146
|
+
* @param {string} _serviceName
|
|
147
147
|
*/
|
|
148
148
|
factory(_serviceName) {
|
|
149
149
|
console.error(`Unhandled ${_serviceName}`);
|
|
@@ -166,7 +166,7 @@ export class ProviderInjector extends AbstractInjector {
|
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* Factory method for creating services.
|
|
169
|
-
* @param {
|
|
169
|
+
* @param {string} caller - The name of the caller requesting the service.
|
|
170
170
|
* @throws {Error} If the provider is unknown.
|
|
171
171
|
*/
|
|
172
172
|
factory(caller) {
|
|
@@ -204,7 +204,7 @@ export class InjectorService extends AbstractInjector {
|
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
206
|
*
|
|
207
|
-
* @param {
|
|
207
|
+
* @param {string} name
|
|
208
208
|
* @returns {boolean}
|
|
209
209
|
*/
|
|
210
210
|
has(name) {
|
|
@@ -220,15 +220,15 @@ export class InjectorService extends AbstractInjector {
|
|
|
220
220
|
// Helpers
|
|
221
221
|
|
|
222
222
|
/**
|
|
223
|
-
* @param {
|
|
224
|
-
* @returns {
|
|
223
|
+
* @param {string} fn
|
|
224
|
+
* @returns {string}
|
|
225
225
|
*/
|
|
226
226
|
function stringifyFn(fn) {
|
|
227
227
|
return Function.prototype.toString.call(fn);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
|
-
* @param {
|
|
231
|
+
* @param {string} fn
|
|
232
232
|
* @returns {Array<any>}
|
|
233
233
|
*/
|
|
234
234
|
function extractArgs(fn) {
|
|
@@ -238,7 +238,7 @@ function extractArgs(fn) {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/**
|
|
241
|
-
* @param {
|
|
241
|
+
* @param {string} func
|
|
242
242
|
* @returns {boolean}
|
|
243
243
|
*/
|
|
244
244
|
function isClass(func) {
|
|
@@ -249,7 +249,7 @@ function isClass(func) {
|
|
|
249
249
|
*
|
|
250
250
|
* @param {any} fn
|
|
251
251
|
* @param {boolean} strictDi
|
|
252
|
-
* @param {
|
|
252
|
+
* @param {string} name
|
|
253
253
|
* @returns {Array<string>}
|
|
254
254
|
*/
|
|
255
255
|
function annotate(fn, strictDi, name) {
|
|
@@ -266,7 +266,7 @@ function annotate(fn, strictDi, name) {
|
|
|
266
266
|
name,
|
|
267
267
|
);
|
|
268
268
|
}
|
|
269
|
-
argDecl = extractArgs(/** @type {
|
|
269
|
+
argDecl = extractArgs(/** @type {string} */ (fn));
|
|
270
270
|
argDecl[1].split(FN_ARG_SPLIT).forEach(function (arg) {
|
|
271
271
|
arg.replace(FN_ARG, function (_all, _underscore, name) {
|
|
272
272
|
$inject.push(name);
|
package/src/core/di/ng-module.js
CHANGED
|
@@ -25,8 +25,8 @@ export const CONTROLLER_LITERAL = "$controllerProvider";
|
|
|
25
25
|
*/
|
|
26
26
|
export class NgModule {
|
|
27
27
|
/**
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {Array<
|
|
28
|
+
* @param {string} name - Name of the module
|
|
29
|
+
* @param {Array<string>} requires - List of modules which the injector will load before the current module
|
|
30
30
|
* @param {Function} [configFn]
|
|
31
31
|
*/
|
|
32
32
|
constructor(name, requires, configFn) {
|
|
@@ -1796,7 +1796,7 @@ describe("$location", () => {
|
|
|
1796
1796
|
|
|
1797
1797
|
// afterEach(() => {
|
|
1798
1798
|
// dealoc(root);
|
|
1799
|
-
// dealoc(
|
|
1799
|
+
// dealoc(document.body);
|
|
1800
1800
|
// });
|
|
1801
1801
|
|
|
1802
1802
|
// it("should rewrite rel link to new url when history enabled on new browser", () => {
|
|
@@ -2303,7 +2303,7 @@ describe("$location", () => {
|
|
|
2303
2303
|
// }),
|
|
2304
2304
|
// setupRewriteChecks(),
|
|
2305
2305
|
// ($browser) => {
|
|
2306
|
-
// const rightClick =
|
|
2306
|
+
// const rightClick = document.createEvent("MouseEvents");
|
|
2307
2307
|
// rightClick.initMouseEvent(
|
|
2308
2308
|
// "click",
|
|
2309
2309
|
// true,
|
|
@@ -2441,12 +2441,12 @@ describe("$location", () => {
|
|
|
2441
2441
|
// });
|
|
2442
2442
|
// inject(($location) => {
|
|
2443
2443
|
// // make IE happy
|
|
2444
|
-
// JQLite(
|
|
2444
|
+
// JQLite(document.body).html(
|
|
2445
2445
|
// '<a href="http://server/test.html">link</a>',
|
|
2446
2446
|
// );
|
|
2447
2447
|
|
|
2448
2448
|
// const event = {
|
|
2449
|
-
// target: JQLite(
|
|
2449
|
+
// target: JQLite(document.body).find("a")[0],
|
|
2450
2450
|
// preventDefault: jasmine.createSpy("preventDefault"),
|
|
2451
2451
|
// isDefaultPrevented: jasmine.createSpy().and.returnValue(false),
|
|
2452
2452
|
// };
|
|
@@ -2481,12 +2481,12 @@ describe("$location", () => {
|
|
|
2481
2481
|
// $location,
|
|
2482
2482
|
// ) => {
|
|
2483
2483
|
// // make IE happy
|
|
2484
|
-
// JQLite(
|
|
2484
|
+
// JQLite(document.body).html(
|
|
2485
2485
|
// '<a href="http://server/index.html#test">link</a>',
|
|
2486
2486
|
// );
|
|
2487
2487
|
|
|
2488
2488
|
// const event = {
|
|
2489
|
-
// target: JQLite(
|
|
2489
|
+
// target: JQLite(document.body).find("a")[0],
|
|
2490
2490
|
// preventDefault: jasmine.createSpy("preventDefault"),
|
|
2491
2491
|
// isDefaultPrevented: jasmine.createSpy().and.returnValue(false),
|
|
2492
2492
|
// };
|
|
@@ -2920,7 +2920,7 @@ describe("$location", () => {
|
|
|
2920
2920
|
// function ($rootElement, $compile, $rootScope) {
|
|
2921
2921
|
// $rootElement.html('<a href="http://server/#!/somePath">link</a>');
|
|
2922
2922
|
// $compile($rootElement)($rootScope);
|
|
2923
|
-
// JQLite(
|
|
2923
|
+
// JQLite(document.body).append($rootElement);
|
|
2924
2924
|
// },
|
|
2925
2925
|
// );
|
|
2926
2926
|
|
|
@@ -2951,7 +2951,7 @@ describe("$location", () => {
|
|
|
2951
2951
|
// return function ($rootElement, $compile, $rootScope) {
|
|
2952
2952
|
// $rootElement.html('<a href="http://server/somePath">link</a>');
|
|
2953
2953
|
// $compile($rootElement)($rootScope);
|
|
2954
|
-
// JQLite(
|
|
2954
|
+
// JQLite(document.body).append($rootElement);
|
|
2955
2955
|
// };
|
|
2956
2956
|
// });
|
|
2957
2957
|
|
|
@@ -3313,7 +3313,7 @@ describe("$location", () => {
|
|
|
3313
3313
|
// function mockUpBrowser(options) {
|
|
3314
3314
|
// module(($windowProvider, $browserProvider) => {
|
|
3315
3315
|
// let browser;
|
|
3316
|
-
// const parser =
|
|
3316
|
+
// const parser = document.createElement("a");
|
|
3317
3317
|
// parser.href = options.initialUrl;
|
|
3318
3318
|
|
|
3319
3319
|
// $windowProvider.$get = function () {
|
package/src/core/sce/sce.spec.js
CHANGED
|
@@ -522,16 +522,16 @@ describe("SCE", () => {
|
|
|
522
522
|
|
|
523
523
|
let baseElem;
|
|
524
524
|
beforeEach(() => {
|
|
525
|
-
baseElem =
|
|
525
|
+
baseElem = document.createElement("BASE");
|
|
526
526
|
baseElem.setAttribute(
|
|
527
527
|
"href",
|
|
528
528
|
`${window.location.protocol}//foo.example.com/path/`,
|
|
529
529
|
);
|
|
530
|
-
|
|
530
|
+
document.head.appendChild(baseElem);
|
|
531
531
|
});
|
|
532
532
|
|
|
533
533
|
afterEach(() => {
|
|
534
|
-
|
|
534
|
+
document.head.removeChild(baseElem);
|
|
535
535
|
});
|
|
536
536
|
|
|
537
537
|
it("should allow relative URLs", () => {
|
|
@@ -1095,7 +1095,7 @@ describe("Scope", function () {
|
|
|
1095
1095
|
|
|
1096
1096
|
it("should watch array-like objects like arrays", () => {
|
|
1097
1097
|
logs = [];
|
|
1098
|
-
$rootScope.obj =
|
|
1098
|
+
$rootScope.obj = document.getElementsByTagName("src");
|
|
1099
1099
|
$rootScope.$digest();
|
|
1100
1100
|
|
|
1101
1101
|
expect(logs.length).toBeTruthy();
|
|
@@ -5,7 +5,7 @@ import { isString } from "../../shared/utils";
|
|
|
5
5
|
* @typedef {"http"|"https"} HttpProtocol
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
const urlParsingNode =
|
|
8
|
+
const urlParsingNode = document.createElement("a");
|
|
9
9
|
const originUrl = urlResolve(window.location.href);
|
|
10
10
|
let baseUrlParsingNode;
|
|
11
11
|
|
|
@@ -126,13 +126,13 @@ export function urlsAreSameOrigin(url1, url2) {
|
|
|
126
126
|
* @returns {string}
|
|
127
127
|
*/
|
|
128
128
|
export function getBaseUrl() {
|
|
129
|
-
if (
|
|
130
|
-
return
|
|
129
|
+
if (document.baseURI) {
|
|
130
|
+
return document.baseURI;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// `document.baseURI` is available everywhere except IE
|
|
134
134
|
if (!baseUrlParsingNode) {
|
|
135
|
-
baseUrlParsingNode =
|
|
135
|
+
baseUrlParsingNode = document.createElement("a");
|
|
136
136
|
baseUrlParsingNode.href = ".";
|
|
137
137
|
|
|
138
138
|
// Work-around for IE bug described in Implementation Notes. The fix in `urlResolve()` is not
|
|
@@ -65,7 +65,7 @@ describe("urlUtils", () => {
|
|
|
65
65
|
|
|
66
66
|
expectIsSameOrigin("path", true);
|
|
67
67
|
|
|
68
|
-
const origin = urlResolve(
|
|
68
|
+
const origin = urlResolve(document.location.href);
|
|
69
69
|
expectIsSameOrigin(`//${origin.host}/path`, true);
|
|
70
70
|
|
|
71
71
|
// Different domain.
|
|
@@ -10,7 +10,7 @@ describe("boolean attr directives", () => {
|
|
|
10
10
|
createInjector([
|
|
11
11
|
"ng",
|
|
12
12
|
($provide) => {
|
|
13
|
-
$provide.value("$rootElement",
|
|
13
|
+
$provide.value("$rootElement", document.body);
|
|
14
14
|
},
|
|
15
15
|
]).invoke((_$compile_, _$rootScope_, _$rootElement_) => {
|
|
16
16
|
$compile = _$compile_;
|
|
@@ -6,8 +6,18 @@ function classDirective(name, selector) {
|
|
|
6
6
|
|
|
7
7
|
return [
|
|
8
8
|
"$parse",
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {import("../../core/parser/parse.js").ParseService} $parse
|
|
12
|
+
* @returns {import("../../types").Directive}
|
|
13
|
+
*/
|
|
9
14
|
($parse) => ({
|
|
10
15
|
restrict: "EA",
|
|
16
|
+
/**
|
|
17
|
+
* @param {import("../../core/scope/scope").Scope} scope
|
|
18
|
+
* @param {import("../../shared/jqlite/jqlite").JQLite} element
|
|
19
|
+
* @param {import("../../core/compile/attributes").Attributes} attr
|
|
20
|
+
*/
|
|
11
21
|
link(scope, element, attr) {
|
|
12
22
|
let classCounts = element.data("$classCounts");
|
|
13
23
|
let oldModulo = true;
|
|
@@ -165,96 +175,6 @@ function classDirective(name, selector) {
|
|
|
165
175
|
}
|
|
166
176
|
}
|
|
167
177
|
|
|
168
|
-
/**
|
|
169
|
-
* The `ngClass` directive allows you to dynamically set CSS classes on an HTML element by databinding
|
|
170
|
-
* an expression that represents all classes to be added.
|
|
171
|
-
*
|
|
172
|
-
* The directive operates in three different ways, depending on which of three types the expression
|
|
173
|
-
* evaluates to:
|
|
174
|
-
*
|
|
175
|
-
* 1. If the expression evaluates to a string, the string should be one or more space-delimited class
|
|
176
|
-
* names.
|
|
177
|
-
*
|
|
178
|
-
* 2. If the expression evaluates to an object, then for each key-value pair of the
|
|
179
|
-
* object with a truthy value the corresponding key is used as a class name.
|
|
180
|
-
*
|
|
181
|
-
* 3. If the expression evaluates to an array, each element of the array should either be a string as in
|
|
182
|
-
* type 1 or an object as in type 2. This means that you can mix strings and objects together in an array
|
|
183
|
-
* to give you more control over what CSS classes appear. See the code below for an example of this.
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* The directive won't add duplicate classes if a particular class was already set.
|
|
187
|
-
*
|
|
188
|
-
* When the expression changes, the previously added classes are removed and only then are the
|
|
189
|
-
* new classes added.
|
|
190
|
-
*
|
|
191
|
-
* @knownIssue
|
|
192
|
-
* You should not use {@link guide/interpolation interpolation} in the value of the `class`
|
|
193
|
-
* attribute, when using the `ngClass` directive on the same element.
|
|
194
|
-
* See {@link guide/interpolation#known-issues here} for more info.
|
|
195
|
-
*
|
|
196
|
-
* @animations
|
|
197
|
-
* | Animation | Occurs |
|
|
198
|
-
* |----------------------------------|-------------------------------------|
|
|
199
|
-
* | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
|
|
200
|
-
* | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
|
|
201
|
-
* | {@link ng.$animate#setClass setClass} | just before classes are added and classes are removed from the element at the same time |
|
|
202
|
-
*
|
|
203
|
-
* ### ngClass and pre-existing CSS3 Transitions/Animations
|
|
204
|
-
The ngClass directive still supports CSS3 Transitions/Animations even if they do not follow the ngAnimate CSS naming structure.
|
|
205
|
-
Upon animation ngAnimate will apply supplementary CSS classes to track the start and end of an animation, but this will not hinder
|
|
206
|
-
any pre-existing CSS transitions already on the element. To get an idea of what happens during a class-based animation, be sure
|
|
207
|
-
to view the step by step details of {@link $animate#addClass $animate.addClass} and
|
|
208
|
-
{@link $animate#removeClass $animate.removeClass}.
|
|
209
|
-
*
|
|
210
|
-
* @param {String} ngClass {@link guide/expression Expression} to eval. The result
|
|
211
|
-
* of the evaluation can be a string representing space delimited class
|
|
212
|
-
* names, an array, or a map of class names to boolean values. In the case of a map, the
|
|
213
|
-
* names of the properties whose values are truthy will be added as css classes to the
|
|
214
|
-
* element.
|
|
215
|
-
*
|
|
216
|
-
*/
|
|
217
178
|
export const ngClassDirective = classDirective("", true);
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* The `ngClassOdd` and `ngClassEven` directives work exactly as
|
|
221
|
-
* {@link ng.directive:ngClass ngClass}, except they work in
|
|
222
|
-
* conjunction with `ngRepeat` and take effect only on odd (even) rows.
|
|
223
|
-
*
|
|
224
|
-
* This directive can be applied only within the scope of an
|
|
225
|
-
* {@link ng.directive:ngRepeat ngRepeat}.
|
|
226
|
-
*
|
|
227
|
-
* @animations
|
|
228
|
-
* | Animation | Occurs |
|
|
229
|
-
* |----------------------------------|-------------------------------------|
|
|
230
|
-
* | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
|
|
231
|
-
* | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
|
|
232
|
-
*
|
|
233
|
-
* @element ANY
|
|
234
|
-
* @param {String} ngClassOdd {@link guide/expression Expression} to eval. The result
|
|
235
|
-
* of the evaluation can be a string representing space delimited class names or an array.
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*/
|
|
239
179
|
export const ngClassOddDirective = classDirective("Odd", 0);
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* The `ngClassOdd` and `ngClassEven` directives work exactly as
|
|
243
|
-
* {@link ng.directive:ngClass ngClass}, except they work in
|
|
244
|
-
* conjunction with `ngRepeat` and take effect only on odd (even) rows.
|
|
245
|
-
*
|
|
246
|
-
* This directive can be applied only within the scope of an
|
|
247
|
-
* {@link ng.directive:ngRepeat ngRepeat}.
|
|
248
|
-
*
|
|
249
|
-
* @animations
|
|
250
|
-
* | Animation | Occurs |
|
|
251
|
-
* |----------------------------------|-------------------------------------|
|
|
252
|
-
* | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
|
|
253
|
-
* | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
|
|
254
|
-
*
|
|
255
|
-
* @element ANY
|
|
256
|
-
* @param {String} ngClassEven {@link guide/expression Expression} to eval. The
|
|
257
|
-
* result of the evaluation can be a string representing space delimited class names or an array.
|
|
258
|
-
*
|
|
259
|
-
*/
|
|
260
180
|
export const ngClassEvenDirective = classDirective("Even", 1);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/\*\*
|
|
2
|
+
|
|
3
|
+
- The `ngClass` directive allows you to dynamically set CSS classes on an HTML element by databinding
|
|
4
|
+
- an expression that represents all classes to be added.
|
|
5
|
+
-
|
|
6
|
+
- The directive operates in three different ways, depending on which of three types the expression
|
|
7
|
+
- evaluates to:
|
|
8
|
+
-
|
|
9
|
+
- 1. If the expression evaluates to a string, the string should be one or more space-delimited class
|
|
10
|
+
- names.
|
|
11
|
+
-
|
|
12
|
+
- 2. If the expression evaluates to an object, then for each key-value pair of the
|
|
13
|
+
- object with a truthy value the corresponding key is used as a class name.
|
|
14
|
+
-
|
|
15
|
+
- 3. If the expression evaluates to an array, each element of the array should either be a string as in
|
|
16
|
+
- type 1 or an object as in type 2. This means that you can mix strings and objects together in an array
|
|
17
|
+
- to give you more control over what CSS classes appear. See the code below for an example of this.
|
|
18
|
+
-
|
|
19
|
+
-
|
|
20
|
+
- The directive won't add duplicate classes if a particular class was already set.
|
|
21
|
+
-
|
|
22
|
+
- When the expression changes, the previously added classes are removed and only then are the
|
|
23
|
+
- new classes added.
|
|
24
|
+
-
|
|
25
|
+
- @knownIssue
|
|
26
|
+
- You should not use {@link guide/interpolation interpolation} in the value of the `class`
|
|
27
|
+
- attribute, when using the `ngClass` directive on the same element.
|
|
28
|
+
- See {@link guide/interpolation#known-issues here} for more info.
|
|
29
|
+
-
|
|
30
|
+
- @animations
|
|
31
|
+
- | Animation | Occurs |
|
|
32
|
+
- |----------------------------------|-------------------------------------|
|
|
33
|
+
- | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
|
|
34
|
+
- | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
|
|
35
|
+
- | {@link ng.$animate#setClass setClass} | just before classes are added and classes are removed from the element at the same time |
|
|
36
|
+
-
|
|
37
|
+
- ### ngClass and pre-existing CSS3 Transitions/Animations
|
|
38
|
+
The ngClass directive still supports CSS3 Transitions/Animations even if they do not follow the ngAnimate CSS naming structure.
|
|
39
|
+
Upon animation ngAnimate will apply supplementary CSS classes to track the start and end of an animation, but this will not hinder
|
|
40
|
+
any pre-existing CSS transitions already on the element. To get an idea of what happens during a class-based animation, be sure
|
|
41
|
+
to view the step by step details of {@link $animate#addClass $animate.addClass} and
|
|
42
|
+
{@link $animate#removeClass $animate.removeClass}.
|
|
43
|
+
-
|
|
44
|
+
- @param {String} ngClass {@link guide/expression Expression} to eval. The result
|
|
45
|
+
- of the evaluation can be a string representing space delimited class
|
|
46
|
+
- names, an array, or a map of class names to boolean values. In the case of a map, the
|
|
47
|
+
- names of the properties whose values are truthy will be added as css classes to the
|
|
48
|
+
- element.
|
|
49
|
+
- \*/
|
|
50
|
+
|
|
51
|
+
/\*\*
|
|
52
|
+
|
|
53
|
+
- The `ngClassOdd` and `ngClassEven` directives work exactly as
|
|
54
|
+
- {@link ng.directive:ngClass ngClass}, except they work in
|
|
55
|
+
- conjunction with `ngRepeat` and take effect only on odd (even) rows.
|
|
56
|
+
-
|
|
57
|
+
- This directive can be applied only within the scope of an
|
|
58
|
+
- {@link ng.directive:ngRepeat ngRepeat}.
|
|
59
|
+
-
|
|
60
|
+
- @animations
|
|
61
|
+
- | Animation | Occurs |
|
|
62
|
+
- |----------------------------------|-------------------------------------|
|
|
63
|
+
- | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
|
|
64
|
+
- | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
|
|
65
|
+
-
|
|
66
|
+
- @element ANY
|
|
67
|
+
- @param {string} ngClassOdd {@link guide/expression Expression} to eval. The result
|
|
68
|
+
- of the evaluation can be a string representing space delimited class names or an array.
|
|
69
|
+
-
|
|
70
|
+
- \*/
|
|
71
|
+
|
|
72
|
+
/\*\*
|
|
73
|
+
|
|
74
|
+
- The `ngClassOdd` and `ngClassEven` directives work exactly as
|
|
75
|
+
- {@link ng.directive:ngClass ngClass}, except they work in
|
|
76
|
+
- conjunction with `ngRepeat` and take effect only on odd (even) rows.
|
|
77
|
+
-
|
|
78
|
+
- This directive can be applied only within the scope of an
|
|
79
|
+
- {@link ng.directive:ngRepeat ngRepeat}.
|
|
80
|
+
-
|
|
81
|
+
- @animations
|
|
82
|
+
- | Animation | Occurs |
|
|
83
|
+
- |----------------------------------|-------------------------------------|
|
|
84
|
+
- | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
|
|
85
|
+
- | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
|
|
86
|
+
-
|
|
87
|
+
- @element ANY
|
|
88
|
+
- @param {string} ngClassEven {@link guide/expression Expression} to eval. The
|
|
89
|
+
- result of the evaluation can be a string representing space delimited class names or an array.
|
|
90
|
+
- \*/
|
|
@@ -737,7 +737,7 @@ describe("ngClass", () => {
|
|
|
737
737
|
// module("ngAnimateMock");
|
|
738
738
|
// inject(($compile, $rootScope, $animate, $timeout) => {
|
|
739
739
|
// element = angular.element('<div ng-class="val"></div>');
|
|
740
|
-
// const body = JQLite(
|
|
740
|
+
// const body = JQLite(document.body);
|
|
741
741
|
// body.append(element);
|
|
742
742
|
// $compile(element)($rootScope);
|
|
743
743
|
|
|
@@ -112,18 +112,6 @@ describe("ngController", () => {
|
|
|
112
112
|
expect(element.text()).toBe("Hello Adam!");
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
it("should instantiate controller defined on scope", () => {
|
|
116
|
-
$rootScope.VojtaGreeter = function ($scope) {
|
|
117
|
-
$scope.name = "Vojta";
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
element = $compile('<div ng-controller="VojtaGreeter">{{name}}</div>')(
|
|
121
|
-
$rootScope,
|
|
122
|
-
);
|
|
123
|
-
$rootScope.$digest();
|
|
124
|
-
expect(element.text()).toBe("Vojta");
|
|
125
|
-
});
|
|
126
|
-
|
|
127
115
|
it("should work with ngInclude on the same element", (done) => {
|
|
128
116
|
element = JQLite(
|
|
129
117
|
'<div><div ng-controller="Greeter" ng-include="\'/mock/interpolation\'"></div></div>',
|
|
@@ -419,7 +419,7 @@ describe("form", () => {
|
|
|
419
419
|
);
|
|
420
420
|
// Support: Chrome 60+ (on Windows)
|
|
421
421
|
// We need to add the form to the DOM in order for `submit` events to be properly fired.
|
|
422
|
-
|
|
422
|
+
document.body.appendChild(doc[0]);
|
|
423
423
|
|
|
424
424
|
const assertPreventDefaultListener = function (e) {
|
|
425
425
|
reloadPrevented = e.defaultPrevented || e.returnValue === false;
|
|
@@ -1404,7 +1404,7 @@ describe("form", () => {
|
|
|
1404
1404
|
let myModule;
|
|
1405
1405
|
|
|
1406
1406
|
beforeEach(() => {
|
|
1407
|
-
let dummy =
|
|
1407
|
+
let dummy = document.getElementById("dummy");
|
|
1408
1408
|
doc = JQLite('<form name="myForm"></form>');
|
|
1409
1409
|
JQLite(dummy).append(doc);
|
|
1410
1410
|
let angular = new Angular();
|
|
@@ -1423,7 +1423,7 @@ describe("form", () => {
|
|
|
1423
1423
|
afterEach(() => {
|
|
1424
1424
|
dealoc(doc);
|
|
1425
1425
|
dealoc(dummy);
|
|
1426
|
-
|
|
1426
|
+
document.getElementById("dummy").innerHTML = "";
|
|
1427
1427
|
});
|
|
1428
1428
|
|
|
1429
1429
|
it("should trigger an animation when invalid", (done) => {
|