Skip to content
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

Make DOMException globally available #39098

Closed
jimmywarting opened this issue Jun 20, 2021 · 1 comment
Closed

Make DOMException globally available #39098

jimmywarting opened this issue Jun 20, 2021 · 1 comment
Labels
feature request Issues that request new features to be added to Node.js.

Comments

@jimmywarting
Copy link

Having to do this is bad code smell

if (!globalThis.DOMException) {
  try {
    const { MessageChannel } = require('worker_threads'),
    port = new MessageChannel().port1,
    ab = new ArrayBuffer()
    port.postMessage(ab, [ab, ab])
  } catch (err) {
    err.constructor.name === 'DOMException' && (
      globalThis.DOMException = err.constructor
    )
  }
}

Since we are aligning more with Web standard APIs now days with the arise of URL, URLSearchParams, Event & EventTarget, MessageChannel, Workers, BroadcastChannel, Blob, File, AbortController, atob, bota, TextEncoder, TextDecoder etc
It would only start to make sense to expose DOMException globally so you are able to check if a error is a instances of DOMException.
Pollyfills need this Error class also.
And more feature web standard apis is probably going to need it.

@himself65 himself65 added the feature request Issues that request new features to be added to Node.js. label Jun 21, 2021
@XadillaX
Copy link
Contributor

If nessesary, I will do this after #39105 is landed.

XadillaX added a commit to XadillaX/node that referenced this issue Jun 28, 2021
XadillaX added a commit to XadillaX/node that referenced this issue Jun 28, 2021
XadillaX added a commit to XadillaX/node that referenced this issue Jun 28, 2021
XadillaX added a commit to XadillaX/node that referenced this issue Jun 28, 2021
XadillaX added a commit to XadillaX/node that referenced this issue Jun 30, 2021
XadillaX added a commit to XadillaX/node that referenced this issue Jun 30, 2021
XadillaX added a commit to XadillaX/node that referenced this issue Jun 30, 2021
XadillaX added a commit to XadillaX/node that referenced this issue Jun 30, 2021
@jasnell jasnell closed this as completed in e4b1fb5 Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants