Skip to content

chore: enable strict apply, bind, and call #18172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2020

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba added P2 The issue is important to a large percentage of users, with a workaround G This is is related to a Google internal issue labels Jan 14, 2020
@mmalerba mmalerba requested a review from jelbourn January 14, 2020 19:15
@mmalerba mmalerba requested review from crisbeto, devversion and a team as code owners January 14, 2020 19:15
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 14, 2020
@@ -1842,14 +1842,22 @@ describe('CdkDrag', () => {
body: document.body,
fullscreenElement: document.createElement('div'),
ELEMENT_NODE: Node.ELEMENT_NODE,
querySelectorAll: function() {
return document.querySelectorAll.apply(document, arguments);
querySelectorAll: function(...args: [string]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be string[]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string[] is a string array of any length, [string] is an array of exactly one string

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we know it'll be one string, couldn't we just declare it like this?

querySelectorAll: (selector: string) {
  return document.querySelectorAll.call(document, selector);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that for these ones where we're just wrapping a function and passing things through, the author was trying to be defensive against future browser API changes by just grabbing all of the arguments and shoving them through. This style preserves that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that I'm the author and I think I did it because it was shorter 😄

Copy link
Member

@devversion devversion Jan 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can only speak for the ZoneJS interceptor, where I also did it that way. I wanted to be on the safe side if a different ZoneJS version is used / when the signature changes. The typings are manually copied, so not very reliable IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah querySelectorAll probably isn't going to change much, but some do, addEventListener has definitely changed over the years

}
},
querySelectorAll: function() {
return document.querySelectorAll.apply(document, arguments);
querySelectorAll: function(...args: [string]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also should be string[]? There are a few more changes like this.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I don't think the string[] vs. [string] matters much for our own unit tests

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jan 14, 2020
@mmalerba mmalerba added the target: patch This PR is targeted for the next patch release label Jan 16, 2020
Copy link
Contributor

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn merged commit 26962a7 into angular:master Jan 22, 2020
jelbourn pushed a commit that referenced this pull request Jan 22, 2020
yifange pushed a commit to yifange/components that referenced this pull request Jan 30, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants