GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: make DOMException attributes configurable and enumerable by joyeecheung · Pull Request #22550 · nodejs/node

Conversation

@joyeecheung

@joyeecheung joyeecheung commented Aug 27, 2018

Copy link
Copy Markdown
Member

The name, message and code attributes of the DOMException
interface should be enumerable and configurable. Aligning
the definition with the Web allows us to use it when
running the Web Platform Tests.

Refs: https://heycam.github.io/webidl/#idl-DOMException
Refs: web-platform-tests/wpt@125950d

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot

nodejs-github-bot commented Aug 27, 2018

Copy link
Copy Markdown
Collaborator

@joyeecheung build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/695/pipeline

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TimothyGu
TimothyGu reviewed Aug 27, 2018
View reviewed changes

@TimothyGu TimothyGu left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for this – not sure how I overlooked it when creating the class. I have become a fan of the way TextEncoder sets the property descriptor bits though, as something like this:

class DOMException ... {
  get name() {
    // …
  }
  get message() {
    // …
  }
}
Object.defineProperties(DOMException.prototype, {
  name: { enumerable: true },
  message: { enumerable: true }
});

This has several advantages, the first being that we can continue to use the nice class syntax, and the second being that Object.getOwnPropertyDescriptor(DOMException.prototype, 'name').get.name would be 'get name' rather than 'get', which is what the IDL spec mandates (see step 3).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
devsnek
devsnek approved these changes Aug 27, 2018
View reviewed changes

@devsnek devsnek left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

couldn't we also use defineIDLClass

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@joyeecheung

joyeecheung commented Aug 27, 2018

Copy link
Copy Markdown
Member Author

I have become a fan of the way TextEncoder sets the property descriptor bits though, as something like this:

@TimothyGu Indeed that looks nicer! Thanks for the suggestion, I'll switch to that.

couldn't we also use defineIDLClass

@devsnek defineIDLClass doesn't seem to deal with attributes ATM..we may want to split that into a separate file dedicated to IDL bindings and add support for attributes later.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax approved these changes Aug 27, 2018
View reviewed changes
@jdalton

jdalton commented Aug 28, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I have mixed feels about Node throwing DOM exceptions.

Update:

I mean if we're doing it, then it should be correct, but I can see this being slippery.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jdalton
jdalton previously requested changes Aug 28, 2018
View reviewed changes

@jdalton jdalton left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

By the IDL shouldn't DOMException be exposed on the global and worker context?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
TimothyGu
TimothyGu approved these changes Aug 28, 2018
View reviewed changes
Comment thread lib/internal/domexception.js Outdated

@TimothyGu TimothyGu Aug 28, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Nit: the configurable: true isn't necessary, as the property is already configurable and Object.defineProperties won't override it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jdalton jdalton Aug 28, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd prefer to be explicit here since Object.defineProperties will read inherited properties of descriptors and Node internals aren't run in an isolated realm yet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TimothyGu TimothyGu Aug 28, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

DOMException was created right above this with its prototype having them as own properties, so that is not an issue here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

domenic and jdalton reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@TimothyGu

TimothyGu commented Aug 28, 2018

Copy link
Copy Markdown
Member

@jdalton, it was a conscious decision when the class was added to not expose it globally, precisely because of the "slippery slope" you mentioned. It is instead only used where it's necessary for compatibility with HTML's MessagePort. In any case, even if we were to do such a change it should be a separate PR, consistent with the tradition of making Web-derived classes globals in their own PRs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jdalton

jdalton commented Aug 28, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

By the IDL does DOMException error have a .code property?

Ah, it does 👍

Update:

Other thought: I'm not sure if it's implied but at least in Chrome the DOMException.prototype has a Symbol.toStringTag value of "DOMException".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TimothyGu

TimothyGu commented Aug 28, 2018

Copy link
Copy Markdown
Member

Other thought: I'm not sure if it's implied but at least in Chrome the DOMException.prototype has a Symbol.toStringTag value of "DOMException".

Oh yeah, this probably needs

  [Symbol.toStringTag]: { configurable: true, value: 'DOMException' }

@jdalton Would you be open to approving this PR once that's fixed?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jdalton

jdalton commented Aug 28, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Would you be open to approving this PR once that's fixed?

Yep, this is already out of the bottle. The main reason I held is because it had more than 2 approvals, meaning a merge could be imminent, and I wanted a bit more discussion.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Aug 29, 2018

Copy link
Copy Markdown
Member Author

Yep, this is already out of the bottle. The main reason I held is because it had more than 2 approvals, meaning a merge could be imminent, and I wanted a bit more discussion.

I don't quite understand...do you want more discussion about the enumerability of these existing properties? If not, in general we open new issues or PRs to discuss, instead of trying to fix everything in one PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jdalton

jdalton commented Aug 29, 2018

Copy link
Copy Markdown
Member

Following up, I dug up spec bits I think are relevant for the Symbol.toStringTag value.

The Symbol.toStringTag addition spec'd for DOMException here:


and

and

While it doesn't state having Symbol.toStringTag on the prototype we could follow Chrome's lead (and it matches how it's handled in other builtins).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Aug 30, 2018

Copy link
Copy Markdown
Member Author

@jdalton Can you open another PR for the Symbol.toStringTag changes? Maybe also with

By the IDL shouldn't DOMException be exposed on the global and worker context?

that you requested? I don't see why those have to be fixed in this particular PR and block this one?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jdalton

jdalton commented Aug 30, 2018

Copy link
Copy Markdown
Member

My requested change is in line with "align DOMException with the Web" and is just an additional line after the 3 properties you've defined.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Aug 30, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

My requested change is in line with "align DOMException with the Web" and is just an additional line after the 3 properties you've defined.

Does it help if I change the commit title to "lib: make DOMException attributes configurable and enumerable"?

I don't mind fixing those myself, but personally even if I fix them in this PR I would not squash them into the first commit when I land the changes, so I'd prefer to have another PR open for that (In general I prefer to squash every commit in one PR whenever possible and keep commits that should be separated in different PR).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BridgeAR
BridgeAR approved these changes Sep 5, 2018
View reviewed changes

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM (no matter if we add the toStringTag in this PR or not and no strong opinion about explicitly adding configurable: true)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@joyeecheung
lib: make DOMException attributes configurable and enumerable
c4d3df8
The `name`, `message` and `code` attributes of the DOMException
interface should be enumerable and configurable. Aligning
the definition with the Web allows us to use it when
running the Web Platform Tests.

Refs: https://heycam.github.io/webidl/#idl-DOMException
@joyeecheung
joyeecheung force-pushed the enum-dom branch from f1dd395 to c4d3df8 Compare September 16, 2018 00:18
@joyeecheung joyeecheung changed the title lib: align DOMException with the Web lib: make DOMException attributes configurable and enumerable Sep 16, 2018
@joyeecheung

joyeecheung commented Sep 16, 2018

Copy link
Copy Markdown
Member Author

Rebased and renamed the PR to focus on the enumerability and configurability. I think other compliance issues can be dealt with in another PR - I'll open one next week if no one picks it up.

CI: https://ci.nodejs.org/job/node-test-pull-request/17211/

devsnek reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Sep 16, 2018

Copy link
Copy Markdown
Member Author

@jdalton Do you insist that this PR fixing the enumerability and configurability cannot land until other attributes get fixed?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jdalton

jdalton commented Sep 16, 2018

Copy link
Copy Markdown
Member

@joyeecheung Yes please. It's a single additional attribute and I believe a reasonable change request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung mentioned this pull request Sep 18, 2018
lib: set Symbol.toStringTag of DOMException #22933
Closed
2 tasks done
@joyeecheung
joyeecheung dismissed jdalton’s stale review September 18, 2018 14:20

Move to #22933

@joyeecheung

joyeecheung commented Sep 18, 2018

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/17292/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung added the blocked PRs that are blocked by other issues or PRs. label Sep 18, 2018
@joyeecheung

joyeecheung commented Sep 18, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Per @jdalton 's request this is blocked by #22933 (though I still don't quite understand the reasoning behind this PR fixing the enumerability and configurability cannot land until other attributes get fixed)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung mentioned this pull request Sep 18, 2018
CI failures: 20180918 nodejs/reliability#16
Closed
@joyeecheung

joyeecheung commented Sep 19, 2018

Copy link
Copy Markdown
Member Author

CI is green

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jdalton
jdalton approved these changes Sep 19, 2018
View reviewed changes
jasnell
jasnell approved these changes Sep 19, 2018
View reviewed changes
joyeecheung added a commit that referenced this pull request Sep 20, 2018
@joyeecheung
lib: set Symbol.toStringTag of DOMException
f91716f
PR-URL: #22933
Refs: #22550
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: John-David Dalton <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@joyeecheung

joyeecheung commented Sep 20, 2018

Copy link
Copy Markdown
Member Author

Landed in 676bd5f, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung closed this Sep 20, 2018
joyeecheung added a commit that referenced this pull request Sep 20, 2018
@joyeecheung
lib: make DOMException attributes configurable and enumerable
676bd5f
The `name`, `message` and `code` attributes of the DOMException
interface should be enumerable and configurable. Aligning
the definition with the Web allows us to use it when
running the Web Platform Tests.

Refs: https://heycam.github.io/webidl/#idl-DOMException

PR-URL: #22550
Refs: web-platform-tests/wpt@125950d
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: John-David Dalton <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this pull request Sep 21, 2018
@joyeecheung @targos
lib: set Symbol.toStringTag of DOMException
5e7b108
PR-URL: #22933
Refs: #22550
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: John-David Dalton <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this pull request Sep 21, 2018
@joyeecheung @targos
lib: make DOMException attributes configurable and enumerable
0140a98
The `name`, `message` and `code` attributes of the DOMException
interface should be enumerable and configurable. Aligning
the definition with the Web allows us to use it when
running the Web Platform Tests.

Refs: https://heycam.github.io/webidl/#idl-DOMException

PR-URL: #22550
Refs: web-platform-tests/wpt@125950d
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: John-David Dalton <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos targos mentioned this pull request Oct 7, 2018
Release proposal: v10.12.0 #23313
Merged
This was referenced Oct 10, 2018
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#225
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#239
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#226
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#240
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#227
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#241
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#242
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#228
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#243
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#229
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@addaleax addaleax addaleax approved these changes
@BridgeAR BridgeAR BridgeAR approved these changes
+3 more reviewers
@TimothyGu TimothyGu TimothyGu approved these changes
@jdalton jdalton jdalton approved these changes
@devsnek devsnek devsnek approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

blocked PRs that are blocked by other issues or PRs.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@joyeecheung @nodejs-github-bot @jdalton @TimothyGu @jasnell @addaleax @devsnek @BridgeAR
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.