@angular-wave/angular.ts 0.0.1 → 0.0.2
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 +1 -1
- package/dist/angular-ts.cjs.js +503 -1686
- package/dist/angular-ts.esm.js +503 -1686
- package/dist/angular-ts.umd.js +503 -1686
- package/package.json +1 -1
- package/src/animations/{animateCss.js → animate-css.js} +0 -1
- package/src/animations/animation.js +428 -431
- package/src/animations/module.js +9 -9
- package/src/core/compile.js +4 -1101
- package/src/core/compile.md +1192 -0
- package/src/core/location.js +1 -1
- package/src/core/utils.js +1 -1
- package/src/directive/a.js +1 -1
- package/src/directive/attrs.js +1 -1
- package/src/directive/csp.md +87 -0
- package/src/directive/input.js +3 -3
- package/src/directive/{ngModel.js → model.js} +1 -1
- package/src/directive/select.js +5 -5
- package/src/jqLite.js +0 -12
- package/src/public.js +24 -24
- package/src/services/log.js +66 -116
- package/src/services/log.md +39 -0
- package/test/jqlite.spec.js +0 -31
- package/test/messages/messages.spec.js +1 -1
- package/test/ng/compile.spec.js +13 -13
- package/test/ng/directive/model-options.spec.js +1 -1
- package/test/ng/directive/model.spec.js +1 -1
- package/test/ng/directive/options.spec.js +61 -61
- package/test/ng/directive/select.spec.js +22 -22
- package/test/ng/http-backend.spec.js +1 -1
- package/test/ng/on.spec.js +1 -1
- package/test/ng/prop.spec.js +54 -62
- package/test/ng/sanitize-uri.spec.js +1 -1
- package/test/ng/scope.spec.js +1 -1
- package/types/jqlite.d.ts +1 -32
- package/src/core/attributes.js +0 -199
- package/src/directive/ngCsp.js +0 -82
- /package/src/animations/{animateCache.js → animate-cache.js} +0 -0
- /package/src/animations/{animateChildrenDirective.js → animate-children-directive.js} +0 -0
- /package/src/animations/{animateCssDriver.js → animate-css-driver.js} +0 -0
- /package/src/animations/{animateJsDriver.js → animate-js-driver.js} +0 -0
- /package/src/animations/{animateJs.js → animate-js.js} +0 -0
- /package/src/animations/{animateQueue.js → animate-queue.js} +0 -0
- /package/src/animations/{ngAnimateSwap.js → animate-swap.js} +0 -0
- /package/src/animations/{rafScheduler.js → raf-scheduler.js} +0 -0
- /package/src/core/{animateCss.js → animate-css.js} +0 -0
- /package/src/core/{animateRunner.js → animate-runner.js} +0 -0
- /package/src/core/{exceptionHandler.js → exception-handler.js} +0 -0
- /package/src/core/{intervalFactory.js → interval-factory.js} +0 -0
- /package/src/core/{rootScope.js → root-scope.js} +0 -0
- /package/src/core/{sanitizeUri.js → sanitize-uri.js} +0 -0
- /package/src/core/{taskTrackerFactory.js → task-tracker-factory.js} +0 -0
- /package/src/directive/{ngClass.js → class.js} +0 -0
- /package/src/directive/{ngController.js → controller.js} +0 -0
- /package/src/directive/{ngIf.js → if.js} +0 -0
- /package/src/directive/{ngInclude.js → include.js} +0 -0
- /package/src/directive/{ngModelOptions.js → model-options.js} +0 -0
- /package/src/directive/{ngOptions.js → options.js} +0 -0
- /package/src/directive/{ngRef.js → ref.js} +0 -0
- /package/src/directive/{ngRepeat.js → repeat.js} +0 -0
- /package/src/directive/{ngShowHide.js → show-hide.js} +0 -0
- /package/src/directive/{ngSwitch.js → switch.js} +0 -0
- /package/src/directive/{ngTransclude.js → transclude.js} +0 -0
- /package/src/{routeToRegExp.js → route-to-reg-exp.js} +0 -0
- /package/src/services/{anchorScroll.js → anchor-scroll.js} +0 -0
- /package/src/services/{cacheFactory.js → cache-factory.js} +0 -0
- /package/src/services/{cookieReader.js → cookie-reader.js} +0 -0
- /package/src/services/{httpBackend.js → http-backend.js} +0 -0
- /package/src/services/{templateRequest.js → template-request.js} +0 -0
- /package/test/ng/{anomate.spec.js → animate.spec.js} +0 -0
package/src/core/location.js
CHANGED
|
@@ -940,7 +940,7 @@ export function $LocationProvider() {
|
|
|
940
940
|
if (isString(rewriteLinks) && isUndefined(elm.attr(rewriteLinks)))
|
|
941
941
|
return;
|
|
942
942
|
|
|
943
|
-
let absHref = elm.
|
|
943
|
+
let absHref = elm[0].href;
|
|
944
944
|
// get the actual href attribute - see
|
|
945
945
|
// http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx
|
|
946
946
|
const relHref = elm.attr("href") || elm.attr("xlink:href");
|
package/src/core/utils.js
CHANGED
|
@@ -605,7 +605,7 @@ export function isElement(node) {
|
|
|
605
605
|
return !!(
|
|
606
606
|
node &&
|
|
607
607
|
(node.nodeName || // We are a direct element.
|
|
608
|
-
(node.
|
|
608
|
+
(node.attr && node.find))
|
|
609
609
|
); // We have an on and find method part of jQuery API.
|
|
610
610
|
}
|
|
611
611
|
|
package/src/directive/a.js
CHANGED
|
@@ -20,7 +20,7 @@ export function htmlAnchorDirective() {
|
|
|
20
20
|
|
|
21
21
|
// SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
|
|
22
22
|
const href =
|
|
23
|
-
toString.call(element.
|
|
23
|
+
toString.call(element[0].href) === "[object SVGAnimatedString]"
|
|
24
24
|
? "xlink:href"
|
|
25
25
|
: "href";
|
|
26
26
|
element.on("click", (event) => {
|
package/src/directive/attrs.js
CHANGED
|
@@ -256,7 +256,7 @@ forEach(["src", "srcset", "href"], (attrName) => {
|
|
|
256
256
|
|
|
257
257
|
if (
|
|
258
258
|
attrName === "href" &&
|
|
259
|
-
toString.call(element.
|
|
259
|
+
toString.call(element[0].href) === "[object SVGAnimatedString]"
|
|
260
260
|
) {
|
|
261
261
|
name = "xlinkHref";
|
|
262
262
|
attr.$attr[name] = "xlink:href";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/\*\*
|
|
2
|
+
|
|
3
|
+
- @ngdoc directive
|
|
4
|
+
- @name ngCsp
|
|
5
|
+
-
|
|
6
|
+
- @restrict A
|
|
7
|
+
- @element ANY
|
|
8
|
+
- @description
|
|
9
|
+
-
|
|
10
|
+
- AngularJS has some features that can conflict with certain restrictions that are applied when using
|
|
11
|
+
- [CSP (Content Security Policy)](https://developer.mozilla.org/en/Security/CSP) rules.
|
|
12
|
+
-
|
|
13
|
+
- If you intend to implement CSP with these rules then you must tell AngularJS not to use these
|
|
14
|
+
- features.
|
|
15
|
+
-
|
|
16
|
+
- This is necessary when developing things like Google Chrome Extensions or Universal Windows Apps.
|
|
17
|
+
-
|
|
18
|
+
-
|
|
19
|
+
- The following default rules in CSP affect AngularJS:
|
|
20
|
+
-
|
|
21
|
+
- - The use of `eval()`, `Function(string)` and similar functions to dynamically create and execute
|
|
22
|
+
- code from strings is forbidden. AngularJS makes use of this in the {@link $parse} service to
|
|
23
|
+
- provide a 30% increase in the speed of evaluating AngularJS expressions. (This CSP rule can be
|
|
24
|
+
- disabled with the CSP keyword `unsafe-eval`, but it is generally not recommended as it would
|
|
25
|
+
- weaken the protections offered by CSP.)
|
|
26
|
+
-
|
|
27
|
+
- - The use of inline resources, such as inline `<script>` and `<style>` elements, are forbidden.
|
|
28
|
+
- This prevents apps from injecting custom styles directly into the document. AngularJS makes use of
|
|
29
|
+
- this to include some CSS rules (e.g. {@link ngCloak} and {@link ngHide}). To make these
|
|
30
|
+
- directives work when a CSP rule is blocking inline styles, you must link to the `angular-csp.css`
|
|
31
|
+
- in your HTML manually. (This CSP rule can be disabled with the CSP keyword `unsafe-inline`, but
|
|
32
|
+
- it is generally not recommended as it would weaken the protections offered by CSP.)
|
|
33
|
+
-
|
|
34
|
+
- If you do not provide `ngCsp` then AngularJS tries to autodetect if CSP is blocking dynamic code
|
|
35
|
+
- creation from strings (e.g., `unsafe-eval` not specified in CSP header) and automatically
|
|
36
|
+
- deactivates this feature in the {@link $parse} service. This autodetection, however, triggers a
|
|
37
|
+
- CSP error to be logged in the console:
|
|
38
|
+
-
|
|
39
|
+
- ```
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
- Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of
|
|
43
|
+
- script in the following Content Security Policy directive: "default-src 'self'". Note that
|
|
44
|
+
- 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
|
|
45
|
+
- ```
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
-
|
|
49
|
+
- This error is harmless but annoying. To prevent the error from showing up, put the `ngCsp`
|
|
50
|
+
- directive on an element of the HTML document that appears before the `<script>` tag that loads
|
|
51
|
+
- the `angular.js` file.
|
|
52
|
+
-
|
|
53
|
+
- _Note: This directive is only available in the `ng-csp` and `data-ng-csp` attribute form._
|
|
54
|
+
-
|
|
55
|
+
- You can specify which of the CSP related AngularJS features should be deactivated by providing
|
|
56
|
+
- a value for the `ng-csp` attribute. The options are as follows:
|
|
57
|
+
-
|
|
58
|
+
- - no-inline-style: this stops AngularJS from injecting CSS styles into the DOM
|
|
59
|
+
-
|
|
60
|
+
- - no-unsafe-eval: this stops AngularJS from optimizing $parse with unsafe eval of strings
|
|
61
|
+
-
|
|
62
|
+
- You can use these values in the following combinations:
|
|
63
|
+
-
|
|
64
|
+
-
|
|
65
|
+
- - No declaration means that AngularJS will assume that you can do inline styles, but it will do
|
|
66
|
+
- a runtime check for unsafe-eval. E.g. `<body>`. This is backwardly compatible with previous
|
|
67
|
+
- versions of AngularJS.
|
|
68
|
+
-
|
|
69
|
+
- - A simple `ng-csp` (or `data-ng-csp`) attribute will tell AngularJS to deactivate both inline
|
|
70
|
+
- styles and unsafe eval. E.g. `<body ng-csp>`. This is backwardly compatible with previous
|
|
71
|
+
- versions of AngularJS.
|
|
72
|
+
-
|
|
73
|
+
- - Specifying only `no-unsafe-eval` tells AngularJS that we must not use eval, but that we can
|
|
74
|
+
- inject inline styles. E.g. `<body ng-csp="no-unsafe-eval">`.
|
|
75
|
+
-
|
|
76
|
+
- - Specifying only `no-inline-style` tells AngularJS that we must not inject styles, but that we can
|
|
77
|
+
- run eval - no automatic check for unsafe eval will occur. E.g. `<body ng-csp="no-inline-style">`
|
|
78
|
+
-
|
|
79
|
+
- - Specifying both `no-unsafe-eval` and `no-inline-style` tells AngularJS that we must not inject
|
|
80
|
+
- styles nor use eval, which is the same as an empty: ng-csp.
|
|
81
|
+
- E.g.`<body ng-csp="no-inline-style;no-unsafe-eval">`
|
|
82
|
+
|
|
83
|
+
// `ngCsp` is not implemented as a proper directive any more, because we need it be processed while
|
|
84
|
+
// we bootstrap the app (before `$parse` is instantiated). For this reason, we just have the `csp()`
|
|
85
|
+
// fn that looks for the `ng-csp` attribute anywhere in the current doc.
|
|
86
|
+
// TODO MOVE CSP to PARSE CONFIG as this should not even be a directive
|
|
87
|
+
\*/
|
package/src/directive/input.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
nextUid,
|
|
16
16
|
equals,
|
|
17
17
|
} from "../core/utils";
|
|
18
|
-
import { ngModelMinErr } from "./
|
|
18
|
+
import { ngModelMinErr } from "./model";
|
|
19
19
|
|
|
20
20
|
// Regex code was initially obtained from SO prior to modification: https://stackoverflow.com/questions/3143070/javascript-regex-iso-datetime#answer-3143231
|
|
21
21
|
export const ISO_DATE_REGEXP =
|
|
@@ -1102,7 +1102,7 @@ export function badInputChecker(scope, element, attr, ctrl, parserName) {
|
|
|
1102
1102
|
|
|
1103
1103
|
if (nativeValidation) {
|
|
1104
1104
|
ctrl.$parsers.push((value) => {
|
|
1105
|
-
const validity = element
|
|
1105
|
+
const validity = element[0][VALIDITY_STATE_PROPERTY] || {};
|
|
1106
1106
|
if (validity.badInput || validity.typeMismatch) {
|
|
1107
1107
|
ctrl.$$parserName = parserName;
|
|
1108
1108
|
return undefined;
|
|
@@ -1759,7 +1759,7 @@ export function ngValueDirective() {
|
|
|
1759
1759
|
// Support: IE9 only
|
|
1760
1760
|
// In IE9 values are converted to string (e.g. `input.value = null` results in `input.value === 'null'`).
|
|
1761
1761
|
const propValue = isDefined(value) ? value : null;
|
|
1762
|
-
element
|
|
1762
|
+
element[0]["value"] = propValue;
|
|
1763
1763
|
attr.$set("value", value);
|
|
1764
1764
|
}
|
|
1765
1765
|
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
isFunction,
|
|
18
18
|
} from "../core/utils";
|
|
19
19
|
import { addSetValidityMethod, nullFormCtrl, setupValidity } from "./form";
|
|
20
|
-
import { defaultModelOptions } from "./
|
|
20
|
+
import { defaultModelOptions } from "./model-options";
|
|
21
21
|
import { startingTag } from "../jqLite";
|
|
22
22
|
export const ngModelMinErr = minErr("ngModel");
|
|
23
23
|
|
package/src/directive/select.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
const noopNgModelController = { $setViewValue: () => {}, $render: () => {} };
|
|
12
12
|
|
|
13
13
|
function setOptionSelectedStatus(optionEl, value) {
|
|
14
|
-
optionEl.
|
|
14
|
+
optionEl[0].selected = value;
|
|
15
15
|
/**
|
|
16
16
|
* When unselecting an option, setting the property to null / false should be enough
|
|
17
17
|
* However, screenreaders might react to the selected attribute instead, see
|
|
@@ -278,7 +278,7 @@ var SelectController = [
|
|
|
278
278
|
|
|
279
279
|
optionAttrs.$observe("value", (newVal) => {
|
|
280
280
|
let removal;
|
|
281
|
-
const previouslySelected = optionElement.
|
|
281
|
+
const previouslySelected = optionElement[0].selected;
|
|
282
282
|
|
|
283
283
|
if (isDefined(hashedVal)) {
|
|
284
284
|
self.removeOption(oldVal);
|
|
@@ -306,7 +306,7 @@ var SelectController = [
|
|
|
306
306
|
self.readValue();
|
|
307
307
|
|
|
308
308
|
let removal;
|
|
309
|
-
const previouslySelected = optionElement.
|
|
309
|
+
const previouslySelected = optionElement[0].selected;
|
|
310
310
|
|
|
311
311
|
if (isDefined(oldVal)) {
|
|
312
312
|
self.removeOption(oldVal);
|
|
@@ -323,7 +323,7 @@ var SelectController = [
|
|
|
323
323
|
// The text content is interpolated
|
|
324
324
|
optionScope.$watch(interpolateTextFn, (newVal, oldVal) => {
|
|
325
325
|
optionAttrs.$set("value", newVal);
|
|
326
|
-
const previouslySelected = optionElement.
|
|
326
|
+
const previouslySelected = optionElement[0].selected;
|
|
327
327
|
if (oldVal !== newVal) {
|
|
328
328
|
self.removeOption(oldVal);
|
|
329
329
|
}
|
|
@@ -342,7 +342,7 @@ var SelectController = [
|
|
|
342
342
|
// Since model updates will also select disabled options (like ngOptions),
|
|
343
343
|
// we only have to handle options becoming disabled, not enabled
|
|
344
344
|
|
|
345
|
-
if (newVal === "true" || (newVal && optionElement.
|
|
345
|
+
if (newVal === "true" || (newVal && optionElement[0].selected)) {
|
|
346
346
|
if (self.multiple) {
|
|
347
347
|
scheduleViewValueUpdate(true);
|
|
348
348
|
} else {
|
package/src/jqLite.js
CHANGED
|
@@ -42,12 +42,10 @@ import { CACHE } from "./core/cache";
|
|
|
42
42
|
* ## AngularJS's jqLite
|
|
43
43
|
* jqLite provides only the following jQuery methods:
|
|
44
44
|
*
|
|
45
|
-
* - [`addClass()`](http://api.jquery.com/addClass/) - Does not support a function as first argument
|
|
46
45
|
* - [`after()`](http://api.jquery.com/after/)
|
|
47
46
|
* - [`append()`](http://api.jquery.com/append/) - Contrary to jQuery, this doesn't clone elements
|
|
48
47
|
* so will not work correctly when invoked on a jqLite object containing more than one DOM node
|
|
49
48
|
* - [`attr()`](http://api.jquery.com/attr/) - Does not support functions as parameters
|
|
50
|
-
* - [`bind()`](http://api.jquery.com/bind/) (_deprecated_, use [`on()`](http://api.jquery.com/on/)) - Does not support namespaces, selectors or eventData
|
|
51
49
|
* - [`children()`](http://api.jquery.com/children/) - Does not support selectors
|
|
52
50
|
* - [`data()`](http://api.jquery.com/data/)
|
|
53
51
|
* - [`empty()`](http://api.jquery.com/empty/)
|
|
@@ -58,7 +56,6 @@ import { CACHE } from "./core/cache";
|
|
|
58
56
|
* - [`one()`](http://api.jquery.com/one/) - Does not support namespaces or selectors
|
|
59
57
|
* - [`parent()`](http://api.jquery.com/parent/) - Does not support selectors
|
|
60
58
|
* - [`prepend()`](http://api.jquery.com/prepend/)
|
|
61
|
-
* - [`prop()`](http://api.jquery.com/prop/)
|
|
62
59
|
* - [`remove()`](http://api.jquery.com/remove/)
|
|
63
60
|
* - [`removeData()`](http://api.jquery.com/removeData/)
|
|
64
61
|
* - [`replaceWith()`](http://api.jquery.com/replaceWith/)
|
|
@@ -669,15 +666,6 @@ forEach(
|
|
|
669
666
|
return ret === null ? undefined : ret;
|
|
670
667
|
}
|
|
671
668
|
},
|
|
672
|
-
|
|
673
|
-
prop(element, name, value) {
|
|
674
|
-
if (isDefined(value)) {
|
|
675
|
-
element[name] = value;
|
|
676
|
-
} else {
|
|
677
|
-
return element[name];
|
|
678
|
-
}
|
|
679
|
-
},
|
|
680
|
-
|
|
681
669
|
text: (function () {
|
|
682
670
|
getText.$dv = "";
|
|
683
671
|
return getText;
|
package/src/public.js
CHANGED
|
@@ -17,28 +17,28 @@ import {
|
|
|
17
17
|
ngClassDirective,
|
|
18
18
|
ngClassEvenDirective,
|
|
19
19
|
ngClassOddDirective,
|
|
20
|
-
} from "./directive/
|
|
20
|
+
} from "./directive/class";
|
|
21
21
|
import { ngCloakDirective } from "./directive/cloak";
|
|
22
|
-
import { ngControllerDirective } from "./directive/
|
|
23
|
-
import { ngHideDirective, ngShowDirective } from "./directive/
|
|
24
|
-
import { ngIfDirective } from "./directive/
|
|
22
|
+
import { ngControllerDirective } from "./directive/controller";
|
|
23
|
+
import { ngHideDirective, ngShowDirective } from "./directive/show-hide";
|
|
24
|
+
import { ngIfDirective } from "./directive/if";
|
|
25
25
|
import {
|
|
26
26
|
ngIncludeDirective,
|
|
27
27
|
ngIncludeFillContentDirective,
|
|
28
|
-
} from "./directive/
|
|
28
|
+
} from "./directive/include";
|
|
29
29
|
import { ngInitDirective } from "./directive/init";
|
|
30
30
|
import { ngNonBindableDirective } from "./directive/non-bindable";
|
|
31
|
-
import { ngRefDirective } from "./directive/
|
|
32
|
-
import { ngRepeatDirective } from "./directive/
|
|
31
|
+
import { ngRefDirective } from "./directive/ref";
|
|
32
|
+
import { ngRepeatDirective } from "./directive/repeat";
|
|
33
33
|
import { ngStyleDirective } from "./directive/style";
|
|
34
34
|
import {
|
|
35
35
|
ngSwitchDirective,
|
|
36
36
|
ngSwitchWhenDirective,
|
|
37
37
|
ngSwitchDefaultDirective,
|
|
38
|
-
} from "./directive/
|
|
39
|
-
import { ngOptionsDirective } from "./directive/
|
|
40
|
-
import { ngTranscludeDirective } from "./directive/
|
|
41
|
-
import { ngModelDirective } from "./directive/
|
|
38
|
+
} from "./directive/switch";
|
|
39
|
+
import { ngOptionsDirective } from "./directive/options";
|
|
40
|
+
import { ngTranscludeDirective } from "./directive/transclude";
|
|
41
|
+
import { ngModelDirective } from "./directive/model";
|
|
42
42
|
import { ngListDirective } from "./directive/list";
|
|
43
43
|
import { ngChangeDirective } from "./directive/change";
|
|
44
44
|
import {
|
|
@@ -47,36 +47,36 @@ import {
|
|
|
47
47
|
patternDirective,
|
|
48
48
|
requiredDirective,
|
|
49
49
|
} from "./directive/validators";
|
|
50
|
-
import { ngModelOptionsDirective } from "./directive/
|
|
50
|
+
import { ngModelOptionsDirective } from "./directive/model-options";
|
|
51
51
|
import { ngAttributeAliasDirectives } from "./directive/attrs";
|
|
52
52
|
import { ngEventDirectives } from "./directive/events";
|
|
53
|
-
import { AnchorScrollProvider } from "./services/
|
|
53
|
+
import { AnchorScrollProvider } from "./services/anchor-scroll";
|
|
54
54
|
import {
|
|
55
55
|
AnimateProvider,
|
|
56
56
|
CoreAnimateJsProvider,
|
|
57
57
|
CoreAnimateQueueProvider,
|
|
58
58
|
} from "./core/animate";
|
|
59
59
|
import { BrowserProvider } from "./services/browser";
|
|
60
|
-
import { CoreAnimateCssProvider } from "./core/
|
|
61
|
-
import { CookieReaderProvider } from "./services/
|
|
60
|
+
import { CoreAnimateCssProvider } from "./core/animate-css";
|
|
61
|
+
import { CookieReaderProvider } from "./services/cookie-reader";
|
|
62
62
|
import {
|
|
63
63
|
AnimateAsyncRunFactoryProvider,
|
|
64
64
|
AnimateRunnerFactoryProvider,
|
|
65
|
-
} from "./core/
|
|
65
|
+
} from "./core/animate-runner";
|
|
66
66
|
import {
|
|
67
67
|
CacheFactoryProvider,
|
|
68
68
|
TemplateCacheProvider,
|
|
69
|
-
} from "./services/
|
|
69
|
+
} from "./services/cache-factory";
|
|
70
70
|
import { $ControllerProvider } from "./core/controller";
|
|
71
71
|
import {
|
|
72
72
|
$DocumentProvider,
|
|
73
73
|
$$IsDocumentHiddenProvider,
|
|
74
74
|
} from "./services/document";
|
|
75
|
-
import { $ExceptionHandlerProvider } from "./core/
|
|
75
|
+
import { $ExceptionHandlerProvider } from "./core/exception-handler";
|
|
76
76
|
import { $FilterProvider } from "./core/filter";
|
|
77
77
|
import { $IntervalProvider } from "./core/interval";
|
|
78
78
|
import { $InterpolateProvider } from "./core/interpolate";
|
|
79
|
-
import { $$IntervalFactoryProvider } from "./core/
|
|
79
|
+
import { $$IntervalFactoryProvider } from "./core/interval-factory";
|
|
80
80
|
import {
|
|
81
81
|
$HttpProvider,
|
|
82
82
|
$HttpParamSerializerProvider,
|
|
@@ -85,17 +85,17 @@ import {
|
|
|
85
85
|
import {
|
|
86
86
|
$HttpBackendProvider,
|
|
87
87
|
$xhrFactoryProvider,
|
|
88
|
-
} from "./services/
|
|
88
|
+
} from "./services/http-backend";
|
|
89
89
|
import { $LocationProvider } from "./core/location";
|
|
90
90
|
import { $LogProvider } from "./services/log";
|
|
91
91
|
import { $ParseProvider } from "./core/parser/parse";
|
|
92
|
-
import { $RootScopeProvider } from "./core/
|
|
92
|
+
import { $RootScopeProvider } from "./core/root-scope";
|
|
93
93
|
import { $QProvider, $$QProvider } from "./core/q";
|
|
94
94
|
import { $SceProvider, $SceDelegateProvider } from "./core/sce";
|
|
95
|
-
import { $$TaskTrackerFactoryProvider } from "./core/
|
|
96
|
-
import { TemplateRequestProvider } from "./services/
|
|
95
|
+
import { $$TaskTrackerFactoryProvider } from "./core/task-tracker-factory";
|
|
96
|
+
import { TemplateRequestProvider } from "./services/template-request";
|
|
97
97
|
import { $TimeoutProvider } from "./core/timeout";
|
|
98
|
-
import { SanitizeUriProvider } from "./core/
|
|
98
|
+
import { SanitizeUriProvider } from "./core/sanitize-uri";
|
|
99
99
|
import { setupModuleLoader } from "./loader";
|
|
100
100
|
import { initAnimateModule } from "./animations/module";
|
|
101
101
|
import { initMessageModule } from "./exts/messages";
|
package/src/services/log.js
CHANGED
|
@@ -1,49 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @ngdoc service
|
|
3
|
-
* @name $log
|
|
4
|
-
*
|
|
5
|
-
* @description
|
|
6
|
-
* Simple service for logging. Default implementation safely writes the message
|
|
7
|
-
* into the browser's console (if present).
|
|
8
|
-
*
|
|
9
|
-
* The main purpose of this service is to simplify debugging and troubleshooting.
|
|
10
|
-
*
|
|
11
|
-
* To reveal the location of the calls to `$log` in the JavaScript console,
|
|
12
|
-
* you can "blackbox" the AngularJS source in your browser:
|
|
13
|
-
*
|
|
14
|
-
* [Mozilla description of blackboxing](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Black_box_a_source).
|
|
15
|
-
* [Chrome description of blackboxing](https://developer.chrome.com/devtools/docs/blackboxing).
|
|
16
|
-
*
|
|
17
|
-
* Note: Not all browsers support blackboxing.
|
|
18
|
-
*
|
|
19
|
-
* The default is to log `debug` messages. You can use
|
|
20
|
-
* {@link ng.$logProvider ng.$logProvider#debugEnabled} to change this.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
<example module="logExample" name="log-service">
|
|
24
|
-
<file name="script.js">
|
|
25
|
-
angular.module('logExample', [])
|
|
26
|
-
.controller('LogController', ['$scope', '$log', function($scope, $log) {
|
|
27
|
-
$scope.$log = $log;
|
|
28
|
-
$scope.message = 'Hello World!';
|
|
29
|
-
}]);
|
|
30
|
-
</file>
|
|
31
|
-
<file name="index.html">
|
|
32
|
-
<div ng-controller="LogController">
|
|
33
|
-
<p>Reload this page with open console, enter text and hit the log button...</p>
|
|
34
|
-
<label>Message:
|
|
35
|
-
<input type="text" ng-model="message" /></label>
|
|
36
|
-
<button ng-click="$log.log(message)">log</button>
|
|
37
|
-
<button ng-click="$log.warn(message)">warn</button>
|
|
38
|
-
<button ng-click="$log.info(message)">info</button>
|
|
39
|
-
<button ng-click="$log.error(message)">error</button>
|
|
40
|
-
<button ng-click="$log.debug(message)">debug</button>
|
|
41
|
-
</div>
|
|
42
|
-
</file>
|
|
43
|
-
</example>
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
import { forEach, isDefined, isError } from "../core/utils";
|
|
1
|
+
import { isError } from "../core/utils";
|
|
47
2
|
|
|
48
3
|
/**
|
|
49
4
|
* @ngdoc provider
|
|
@@ -53,9 +8,10 @@ import { forEach, isDefined, isError } from "../core/utils";
|
|
|
53
8
|
* @description
|
|
54
9
|
* Use the `$logProvider` to configure how the application logs messages
|
|
55
10
|
*/
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
11
|
+
export class $LogProvider {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.debug = true;
|
|
14
|
+
}
|
|
59
15
|
|
|
60
16
|
/**
|
|
61
17
|
* @ngdoc method
|
|
@@ -64,15 +20,15 @@ export function $LogProvider() {
|
|
|
64
20
|
* @param {boolean=} flag enable or disable debug level messages
|
|
65
21
|
* @returns {*} current value if used as getter or itself (chaining) if used as setter
|
|
66
22
|
*/
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
debug = flag;
|
|
23
|
+
debugEnabled(flag) {
|
|
24
|
+
if (typeof flag !== "undefined") {
|
|
25
|
+
this.debug = flag;
|
|
70
26
|
return this;
|
|
71
27
|
}
|
|
72
|
-
return debug;
|
|
73
|
-
}
|
|
28
|
+
return this.debug;
|
|
29
|
+
}
|
|
74
30
|
|
|
75
|
-
|
|
31
|
+
formatError(arg) {
|
|
76
32
|
if (isError(arg)) {
|
|
77
33
|
if (arg.stack) {
|
|
78
34
|
arg =
|
|
@@ -86,75 +42,69 @@ export function $LogProvider() {
|
|
|
86
42
|
return arg;
|
|
87
43
|
}
|
|
88
44
|
|
|
89
|
-
|
|
45
|
+
consoleLog(type) {
|
|
90
46
|
const console = window.console || {};
|
|
91
47
|
const logFn = console[type] || console.log || (() => {});
|
|
92
48
|
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
args.push(formatError(arg));
|
|
97
|
-
});
|
|
98
|
-
return logFn.apply(console, args);
|
|
49
|
+
return (...args) => {
|
|
50
|
+
const formattedArgs = args.map((arg) => this.formatError(arg));
|
|
51
|
+
return logFn.apply(console, formattedArgs);
|
|
99
52
|
};
|
|
100
53
|
}
|
|
101
54
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
log: consoleLog("log"),
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* @ngdoc method
|
|
116
|
-
* @name $log#info
|
|
117
|
-
*
|
|
118
|
-
* @description
|
|
119
|
-
* Write an information message
|
|
120
|
-
*/
|
|
121
|
-
info: consoleLog("info"),
|
|
55
|
+
$get() {
|
|
56
|
+
return {
|
|
57
|
+
/**
|
|
58
|
+
* @ngdoc method
|
|
59
|
+
* @name $log#log
|
|
60
|
+
*
|
|
61
|
+
* @description
|
|
62
|
+
* Write a log message
|
|
63
|
+
*/
|
|
64
|
+
log: this.consoleLog("log"),
|
|
122
65
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @ngdoc method
|
|
68
|
+
* @name $log#info
|
|
69
|
+
*
|
|
70
|
+
* @description
|
|
71
|
+
* Write an information message
|
|
72
|
+
*/
|
|
73
|
+
info: this.consoleLog("info"),
|
|
131
74
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
75
|
+
/**
|
|
76
|
+
* @ngdoc method
|
|
77
|
+
* @name $log#warn
|
|
78
|
+
*
|
|
79
|
+
* @description
|
|
80
|
+
* Write a warning message
|
|
81
|
+
*/
|
|
82
|
+
warn: this.consoleLog("warn"),
|
|
140
83
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const fn = consoleLog("debug");
|
|
84
|
+
/**
|
|
85
|
+
* @ngdoc method
|
|
86
|
+
* @name $log#error
|
|
87
|
+
*
|
|
88
|
+
* @description
|
|
89
|
+
* Write an error message
|
|
90
|
+
*/
|
|
91
|
+
error: this.consoleLog("error"),
|
|
150
92
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
93
|
+
/**
|
|
94
|
+
* @ngdoc method
|
|
95
|
+
* @name $log#debug
|
|
96
|
+
*
|
|
97
|
+
* @description
|
|
98
|
+
* Write a debug message
|
|
99
|
+
*/
|
|
100
|
+
debug: (() => {
|
|
101
|
+
const fn = this.consoleLog("debug");
|
|
102
|
+
return (...args) => {
|
|
103
|
+
if (this.debug) {
|
|
104
|
+
fn.apply(this, args);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
})(),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
160
110
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# $log
|
|
2
|
+
|
|
3
|
+
Simple service for logging. Default implementation safely writes the message into the browser's console (if present).
|
|
4
|
+
|
|
5
|
+
The main purpose of this service is to simplify debugging and troubleshooting.
|
|
6
|
+
|
|
7
|
+
To reveal the location of the calls to `$log` in the JavaScript console, you can "blackbox" the AngularJS source in your browser:
|
|
8
|
+
|
|
9
|
+
- [Mozilla description of blackboxing](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Black_box_a_source).
|
|
10
|
+
- [Chrome description of blackboxing](https://developer.chrome.com/devtools/docs/blackboxing).
|
|
11
|
+
|
|
12
|
+
Note: Not all browsers support blackboxing.
|
|
13
|
+
|
|
14
|
+
The default is to log `debug` messages. You can use [`ng.$logProvider.debugEnabled`](https://docs.angularjs.org/api/ng/provider/$logProvider#debugEnabled) to change this.
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<example module="logExample" name="log-service">
|
|
20
|
+
<file name="script.js">
|
|
21
|
+
angular.module('logExample', []) .controller('LogController', ['$scope',
|
|
22
|
+
'$log', function($scope, $log) { $scope.$log = $log; $scope.message = 'Hello
|
|
23
|
+
World!'; }]);
|
|
24
|
+
</file>
|
|
25
|
+
<file name="index.html">
|
|
26
|
+
<div ng-controller="LogController">
|
|
27
|
+
<p>
|
|
28
|
+
Reload this page with open console, enter text and hit the log button...
|
|
29
|
+
</p>
|
|
30
|
+
<label>Message: <input type="text" ng-model="message" /></label>
|
|
31
|
+
<button ng-click="$log.log(message)">log</button>
|
|
32
|
+
<button ng-click="$log.warn(message)">warn</button>
|
|
33
|
+
<button ng-click="$log.info(message)">info</button>
|
|
34
|
+
<button ng-click="$log.error(message)">error</button>
|
|
35
|
+
<button ng-click="$log.debug(message)">debug</button>
|
|
36
|
+
</div>
|
|
37
|
+
</file>
|
|
38
|
+
</example>
|
|
39
|
+
```
|
package/test/jqlite.spec.js
CHANGED
|
@@ -919,37 +919,6 @@ describe("jqLite", () => {
|
|
|
919
919
|
});
|
|
920
920
|
});
|
|
921
921
|
|
|
922
|
-
describe("prop", () => {
|
|
923
|
-
it("should read element property", () => {
|
|
924
|
-
const elm = jqLite('<div class="foo">a</div>');
|
|
925
|
-
expect(elm.prop("className")).toBe("foo");
|
|
926
|
-
});
|
|
927
|
-
|
|
928
|
-
it("should set element property to a value", () => {
|
|
929
|
-
const elm = jqLite('<div class="foo">a</div>');
|
|
930
|
-
elm.prop("className", "bar");
|
|
931
|
-
expect(elm[0].className).toBe("bar");
|
|
932
|
-
expect(elm.prop("className")).toBe("bar");
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
-
it("should set boolean element property", () => {
|
|
936
|
-
const elm = jqLite('<input type="checkbox">');
|
|
937
|
-
expect(elm.prop("checked")).toBe(false);
|
|
938
|
-
|
|
939
|
-
elm.prop("checked", true);
|
|
940
|
-
expect(elm.prop("checked")).toBe(true);
|
|
941
|
-
|
|
942
|
-
elm.prop("checked", "");
|
|
943
|
-
expect(elm.prop("checked")).toBe(false);
|
|
944
|
-
|
|
945
|
-
elm.prop("checked", "lala");
|
|
946
|
-
expect(elm.prop("checked")).toBe(true);
|
|
947
|
-
|
|
948
|
-
elm.prop("checked", null);
|
|
949
|
-
expect(elm.prop("checked")).toBe(false);
|
|
950
|
-
});
|
|
951
|
-
});
|
|
952
|
-
|
|
953
922
|
describe("text", () => {
|
|
954
923
|
it('should return `""` on empty', () => {
|
|
955
924
|
expect(jqLite().length).toEqual(0);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInjector } from "../../src/injector";
|
|
2
|
-
import { countWatchers } from "../../src/core/
|
|
2
|
+
import { countWatchers } from "../../src/core/root-scope";
|
|
3
3
|
import { publishExternalAPI } from "../../src/public";
|
|
4
4
|
import { isString } from "../../src/core/utils";
|
|
5
5
|
import { jqLite } from "../../src/jqLite";
|