Skip to content

Commit 56273bb

Browse files
author
Anatoly Ostrovsky
committed
Type improvements. Ignore events for scope
1 parent 65eafd9 commit 56273bb

File tree

13 files changed

+112
-314
lines changed

13 files changed

+112
-314
lines changed

@types/animations/animate.d.ts

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -212,74 +212,12 @@ export class AnimateProvider {
212212
*/
213213
enabled: any;
214214
/**
215-
* Cancels the provided animation and applies the end state of the animation.
216-
* Note that this does not cancel the underlying operation, e.g. the setting of classes or
217-
* adding the element to the DOM.
218-
*
219-
* @param {import('./runner/animate-runner.js').AnimateRunner} runner An animation runner returned by an $animate function.
220-
*
221-
* @example
222-
<example module="animationExample" deps="angular-animate.js" animations="true" name="animate-cancel">
223-
<file name="app.js">
224-
angular.module('animationExample', []).component('cancelExample', {
225-
templateUrl: 'template.html',
226-
controller: function($element, $animate) {
227-
this.runner = null;
228-
229-
this.addClass = function() {
230-
this.runner = $animate.addClass($element.querySelectorAll('div'), 'red');
231-
let ctrl = this;
232-
this.runner.finally(function() {
233-
ctrl.runner = null;
234-
});
235-
};
236-
237-
this.removeClass = function() {
238-
this.runner = $animate.removeClass($element.querySelectorAll('div'), 'red');
239-
let ctrl = this;
240-
this.runner.finally(function() {
241-
ctrl.runner = null;
242-
});
243-
};
244-
245-
this.cancel = function() {
246-
$animate.cancel(this.runner);
247-
};
248-
}
249-
});
250-
</file>
251-
<file name="template.html">
252-
<p>
253-
<button id="add" ng-click="$ctrl.addClass()">Add</button>
254-
<button ng-click="$ctrl.removeClass()">Remove</button>
255-
<br>
256-
<button id="cancel" ng-click="$ctrl.cancel()" ng-disabled="!$ctrl.runner">Cancel</button>
257-
<br>
258-
<div id="target">CSS-Animated Text</div>
259-
</p>
260-
</file>
261-
<file name="index.html">
262-
<cancel-example></cancel-example>
263-
</file>
264-
<file name="style.css">
265-
.red-add, .red-remove {
266-
transition: all 4s cubic-bezier(0.250, 0.460, 0.450, 0.940);
267-
}
268-
269-
.red,
270-
.red-add.red-add-active {
271-
color: #FF0000;
272-
font-size: 40px;
273-
}
274-
275-
.red-remove.red-remove-active {
276-
font-size: 10px;
277-
color: black;
278-
}
279-
280-
</file>
281-
</example>
282-
*/
215+
* Cancels the provided animation and applies the end state of the animation.
216+
* Note that this does not cancel the underlying operation, e.g. the setting of classes or
217+
* adding the element to the DOM.
218+
*
219+
* @param {import('./runner/animate-runner.js').AnimateRunner} runner An animation runner returned by an $animate function.
220+
*/
283221
cancel(
284222
runner: import("./runner/animate-runner.js").AnimateRunner,
285223
): void;

@types/core/compile/attributes.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export class Attributes {
22
static $nonscope: boolean;
33
/**
4-
* @param {ng.Scope} $rootScope
4+
* @param {ng.RootScopeService} $rootScope
55
* @param {*} $animate
66
* @param {ng.ExceptionHandlerService} $exceptionHandler
77
* @param {*} $sce
88
* @param {import("../../shared/noderef.js").NodeRef} [nodeRef]
99
* @param {Object} [attributesToCopy]
1010
*/
1111
constructor(
12-
$rootScope: ng.Scope,
12+
$rootScope: ng.RootScopeService,
1313
$animate: any,
1414
$exceptionHandler: ng.ExceptionHandlerService,
1515
$sce: any,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Sanitizer function that processes a URI string and optionally
3+
* treats it as a media URL.
4+
*/
5+
export type SanitizerFn = (
6+
uri: string | null | undefined,
7+
isMediaUrl?: boolean,
8+
) => string | null | undefined;

@types/core/sanitize/sanitize-uri.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ export class SanitizeUriProvider implements ServiceProvider {
3333
regexp?: RegExp | undefined,
3434
): RegExp | SanitizeUriProvider;
3535
/**
36-
* @returns {import("./interface").SanitizerFn}
36+
* @returns {import("./interface.ts").SanitizerFn}
3737
*/
38-
$get: (string | (($window: ng.WindowService) => any))[];
38+
$get: (
39+
| string
40+
| (($window: ng.WindowService) => import("./interface.ts").SanitizerFn)
41+
)[];
3942
}
4043
export type ServiceProvider = import("../../interface.ts").ServiceProvider;

@types/services/sce/sce.d.ts

Lines changed: 4 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -24,85 +24,7 @@ export namespace SCE_CONTEXTS {
2424
* `$sceDelegate` is a service that is used by the `$sce` service to provide {@link ng.$sce Strict
2525
* Contextual Escaping (SCE)} services to AngularTS.
2626
*
27-
* For an overview of this service and the functionnality it provides in AngularTS, see the main
28-
* page for {@link ng.$sce SCE}. The current page is targeted for developers who need to alter how
29-
* SCE works in their application, which shouldn't be needed in most cases.
30-
*
31-
* <div class="alert alert-danger">
32-
* AngularTS strongly relies on contextual escaping for the security of bindings: disabling or
33-
* modifying this might cause cross site scripting (XSS) vulnerabilities. For libraries owners,
34-
* changes to this service will also influence users, so be extra careful and document your changes.
35-
* </div>
36-
*
37-
* Typically, you would configure or override the {@link ng.$sceDelegate $sceDelegate} instead of
38-
* the `$sce` service to customize the way Strict Contextual Escaping works in AngularTS. This is
39-
* because, while the `$sce` provides numerous shorthand methods, etc., you really only need to
40-
* override 3 core functions (`trustAs`, `getTrusted` and `valueOf`) to replace the way things
41-
* work because `$sce` delegates to `$sceDelegate` for these operations.
42-
*
43-
* Refer {@link ng.$sceDelegateProvider $sceDelegateProvider} to configure this service.
44-
*
45-
* The default instance of `$sceDelegate` should work out of the box with little pain. While you
46-
* can override it completely to change the behavior of `$sce`, the common case would
47-
* involve configuring the {@link ng.$sceDelegateProvider $sceDelegateProvider} instead by setting
48-
* your own trusted and banned resource lists for trusting URLs used for loading AngularTS resources
49-
* such as templates. Refer {@link ng.$sceDelegateProvider#trustedResourceUrlList
50-
* $sceDelegateProvider.trustedResourceUrlList} and {@link
51-
* ng.$sceDelegateProvider#bannedResourceUrlList $sceDelegateProvider.bannedResourceUrlList}
52-
*/
53-
/**
54-
*
55-
* The `$sceDelegateProvider` provider allows developers to configure the {@link ng.$sceDelegate
56-
* $sceDelegate service}, used as a delegate for {@link ng.$sce Strict Contextual Escaping (SCE)}.
57-
*
58-
* The `$sceDelegateProvider` allows one to get/set the `trustedResourceUrlList` and
59-
* `bannedResourceUrlList` used to ensure that the URLs used for sourcing AngularTS templates and
60-
* other script-running URLs are safe (all places that use the `$sce.RESOURCE_URL` context). See
61-
* {@link ng.$sceDelegateProvider#trustedResourceUrlList
62-
* $sceDelegateProvider.trustedResourceUrlList} and
63-
* {@link ng.$sceDelegateProvider#bannedResourceUrlList $sceDelegateProvider.bannedResourceUrlList},
64-
*
65-
* For the general details about this service in AngularTS, read the main page for {@link ng.$sce
66-
* Strict Contextual Escaping (SCE)}.
67-
*
68-
* **Example**: Consider the following case. <a name="example"></a>
69-
*
70-
* - your app is hosted at url `http://myapp.example.com/`
71-
* - but some of your templates are hosted on other domains you control such as
72-
* `http://srv01.assets.example.com/`, `http://srv02.assets.example.com/`, etc.
73-
* - and you have an open redirect at `http://myapp.example.com/clickThru?...`.
74-
*
75-
* Here is what a secure configuration for this scenario might look like:
76-
*
77-
* ```
78-
* angular.module('myApp', []).config(function($sceDelegateProvider) {
79-
* $sceDelegateProvider.trustedResourceUrlList([
80-
* // Allow same origin resource loads.
81-
* 'self',
82-
* // Allow loading from our assets domain. Notice the difference between * and **.
83-
* 'http://srv*.assets.example.com/**'
84-
* ]);
85-
*
86-
* // The banned resource URL list overrides the trusted resource URL list so the open redirect
87-
* // here is blocked.
88-
* $sceDelegateProvider.bannedResourceUrlList([
89-
* 'http://myapp.example.com/clickThru**'
90-
* ]);
91-
* });
92-
* ```
93-
* Note that an empty trusted resource URL list will block every resource URL from being loaded, and will require
94-
* you to manually mark each one as trusted with `$sce.trustAsResourceUrl`. However, templates
95-
* requested by {@link ng.$templateRequest $templateRequest} that are present in
96-
* {@link ng.$templateCache $templateCache} will not go through this check. If you have a mechanism
97-
* to populate your templates in that cache at config time, then it is a good idea to remove 'self'
98-
* from the trusted resource URL lsit. This helps to mitigate the security impact of certain types
99-
* of issues, like for instance attacker-controlled `ng-includes`.
100-
*/
101-
/**
102-
* `$sceDelegate` is a service that is used by the `$sce` service to provide {@link ng.$sce Strict
103-
* Contextual Escaping (SCE)} services to AngularTS.
104-
*
105-
* For an overview of this service and the functionnality it provides in AngularTS, see the main
27+
* For an overview of this service and the functionality it provides in AngularTS, see the main
10628
* page for {@link ng.$sce SCE}. The current page is targeted for developers who need to alter how
10729
* SCE works in their application, which shouldn't be needed in most cases.
10830
*
@@ -179,7 +101,7 @@ export namespace SCE_CONTEXTS {
179101
export class SceDelegateProvider {
180102
/**
181103
*
182-
* @param {Array=} trustedResourceUrlList When provided, replaces the trustedResourceUrlList with
104+
* @param {Array=} value When provided, replaces the trustedResourceUrlList with
183105
* the value provided. This must be an array or null. A snapshot of this array is used so
184106
* further changes to the array are ignored.
185107
* Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items
@@ -198,7 +120,7 @@ export class SceDelegateProvider {
198120
* its origin with other apps! It is a good idea to limit it to only your application's directory.
199121
* </div>
200122
*/
201-
trustedResourceUrlList: (value: any, ...args: any[]) => any[];
123+
trustedResourceUrlList: (value?: any[] | undefined, ...args: any[]) => any[];
202124
/**
203125
*
204126
* @param {Array=} bannedResourceUrlList When provided, replaces the `bannedResourceUrlList` with
@@ -226,7 +148,7 @@ export class SceDelegateProvider {
226148
| string
227149
| ((
228150
$injector: ng.InjectorService,
229-
$$sanitizeUri: any,
151+
$$sanitizeUri: import("../../core/sanitize/interface.ts").SanitizerFn,
230152
$exceptionHandler: ng.ExceptionHandlerService,
231153
) => {
232154
trustAs: (type: string, trustedValue: any) => any;
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!--<example module="animationExample" deps="angular-animate.js" animations="true" name="animate-cancel">-->
2+
<!-- <file name="app.js">-->
3+
<!-- angular.module('animationExample', []).component('cancelExample', {-->
4+
<!-- templateUrl: 'template.html',-->
5+
<!-- controller: function($element, $animate) {-->
6+
<!-- this.runner = null;-->
7+
8+
<!-- this.addClass = function() {-->
9+
<!-- this.runner = $animate.addClass($element.querySelectorAll('div'), 'red');-->
10+
<!-- let ctrl = this;-->
11+
<!-- this.runner.finally(function() {-->
12+
<!-- ctrl.runner = null;-->
13+
<!-- });-->
14+
<!-- };-->
15+
16+
<!-- this.removeClass = function() {-->
17+
<!-- this.runner = $animate.removeClass($element.querySelectorAll('div'), 'red');-->
18+
<!-- let ctrl = this;-->
19+
<!-- this.runner.finally(function() {-->
20+
<!-- ctrl.runner = null;-->
21+
<!-- });-->
22+
<!-- };-->
23+
24+
<!-- this.cancel = function() {-->
25+
<!-- $animate.cancel(this.runner);-->
26+
<!-- };-->
27+
<!-- }-->
28+
<!-- });-->
29+
<!-- </file>-->
30+
<!-- <file name="template.html">-->
31+
<!-- <p>-->
32+
<!-- <button id="add" ng-click="$ctrl.addClass()">Add</button>-->
33+
<!-- <button ng-click="$ctrl.removeClass()">Remove</button>-->
34+
<!-- <br>-->
35+
<!-- <button id="cancel" ng-click="$ctrl.cancel()" ng-disabled="!$ctrl.runner">Cancel</button>-->
36+
<!-- <br>-->
37+
<!-- <div id="target">CSS-Animated Text</div>-->
38+
<!-- </p>-->
39+
<!-- </file>-->
40+
<!-- <file name="index.html">-->
41+
<!-- <cancel-example></cancel-example>-->
42+
<!-- </file>-->
43+
<!-- <file name="style.css">-->
44+
<!-- .red-add, .red-remove {-->
45+
<!-- transition: all 4s cubic-bezier(0.250, 0.460, 0.450, 0.940);-->
46+
<!-- }-->
47+
48+
<!-- .red,-->
49+
<!-- .red-add.red-add-active {-->
50+
<!-- color: #FF0000;-->
51+
<!-- font-size: 40px;-->
52+
<!-- }-->
53+
54+
<!-- .red-remove.red-remove-active {-->
55+
<!-- font-size: 10px;-->
56+
<!-- color: black;-->
57+
<!-- }-->
58+
59+
<!-- </file>-->
60+
<!--</example>-->

src/animations/animate.js

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -304,74 +304,12 @@ export function AnimateProvider($provide) {
304304
enabled: $$animateQueue.enabled,
305305

306306
/**
307-
* Cancels the provided animation and applies the end state of the animation.
308-
* Note that this does not cancel the underlying operation, e.g. the setting of classes or
309-
* adding the element to the DOM.
310-
*
311-
* @param {import('./runner/animate-runner.js').AnimateRunner} runner An animation runner returned by an $animate function.
312-
*
313-
* @example
314-
<example module="animationExample" deps="angular-animate.js" animations="true" name="animate-cancel">
315-
<file name="app.js">
316-
angular.module('animationExample', []).component('cancelExample', {
317-
templateUrl: 'template.html',
318-
controller: function($element, $animate) {
319-
this.runner = null;
320-
321-
this.addClass = function() {
322-
this.runner = $animate.addClass($element.querySelectorAll('div'), 'red');
323-
let ctrl = this;
324-
this.runner.finally(function() {
325-
ctrl.runner = null;
326-
});
327-
};
328-
329-
this.removeClass = function() {
330-
this.runner = $animate.removeClass($element.querySelectorAll('div'), 'red');
331-
let ctrl = this;
332-
this.runner.finally(function() {
333-
ctrl.runner = null;
334-
});
335-
};
336-
337-
this.cancel = function() {
338-
$animate.cancel(this.runner);
339-
};
340-
}
341-
});
342-
</file>
343-
<file name="template.html">
344-
<p>
345-
<button id="add" ng-click="$ctrl.addClass()">Add</button>
346-
<button ng-click="$ctrl.removeClass()">Remove</button>
347-
<br>
348-
<button id="cancel" ng-click="$ctrl.cancel()" ng-disabled="!$ctrl.runner">Cancel</button>
349-
<br>
350-
<div id="target">CSS-Animated Text</div>
351-
</p>
352-
</file>
353-
<file name="index.html">
354-
<cancel-example></cancel-example>
355-
</file>
356-
<file name="style.css">
357-
.red-add, .red-remove {
358-
transition: all 4s cubic-bezier(0.250, 0.460, 0.450, 0.940);
359-
}
360-
361-
.red,
362-
.red-add.red-add-active {
363-
color: #FF0000;
364-
font-size: 40px;
365-
}
366-
367-
.red-remove.red-remove-active {
368-
font-size: 10px;
369-
color: black;
370-
}
371-
372-
</file>
373-
</example>
374-
*/
307+
* Cancels the provided animation and applies the end state of the animation.
308+
* Note that this does not cancel the underlying operation, e.g. the setting of classes or
309+
* adding the element to the DOM.
310+
*
311+
* @param {import('./runner/animate-runner.js').AnimateRunner} runner An animation runner returned by an $animate function.
312+
*/
375313
cancel(runner) {
376314
if (runner.cancel) {
377315
runner.cancel();

src/core/compile/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class Attributes {
2121
static $nonscope = true;
2222

2323
/**
24-
* @param {ng.Scope} $rootScope
24+
* @param {ng.RootScopeService} $rootScope
2525
* @param {*} $animate
2626
* @param {ng.ExceptionHandlerService} $exceptionHandler
2727
* @param {*} $sce

0 commit comments

Comments
 (0)