Skip to content

Commit

Permalink
refactor(platform-browser): compatibility with typescript strict flag (
Browse files Browse the repository at this point in the history
…angular#30993)

As part of FW-1265, the `@angular/platform-browser` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
  • Loading branch information
devversion authored and sabeersulaiman committed Sep 6, 2019
1 parent 2ccd491 commit cec86bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/platform-browser/src/browser/browser_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ const _chromeNumKeyPadMap = {
'\x90': 'NumLock'
};

const nodeContains: (a: any, b: any) => boolean = (() => {
const nodeContains: (this: Node, other: Node) => boolean = (() => {
if (global['Node']) {
return global['Node'].prototype.contains || function(node: any) {
return global['Node'].prototype.contains || function(this: Node, node: any) {
return !!(this.compareDocumentPosition(node) & 16);
};
}
Expand Down
14 changes: 8 additions & 6 deletions packages/platform-browser/src/dom/events/dom_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface TaskData {

// a global listener to handle all dom event,
// so we do not need to create a closure every time
const globalListener = function(event: Event) {
const globalListener = function(this: any, event: Event) {
const symbolName = symbolNames[event.type];
if (!symbolName) {
return;
Expand Down Expand Up @@ -123,15 +123,17 @@ export class DomEventsPlugin extends EventManagerPlugin {
}
const delegate = (Event.prototype as any)[stopMethodSymbol] =
Event.prototype.stopImmediatePropagation;
Event.prototype.stopImmediatePropagation = function() {
Event.prototype.stopImmediatePropagation = function(this: any) {
if (this) {
this[stopSymbol] = true;
}

// should call native delegate in case
// in some environment part of the application
// will not use the patched Event
delegate && delegate.apply(this, arguments);
// We should call native delegate in case in some environment part of
// the application will not use the patched Event. Also we cast the
// "arguments" to any since "stopImmediatePropagation" technically does not
// accept any arguments, but we don't know what developers pass through the
// function and we want to not break these calls.
delegate && delegate.apply(this, arguments as any);
};
}

Expand Down

0 comments on commit cec86bb

Please sign in to comment.