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

Google Feedback on 4.4 Beta #1067

Closed
DanielRosenwasser opened this issue Jul 15, 2021 · 9 comments · Fixed by #1123
Closed

Google Feedback on 4.4 Beta #1067

DanielRosenwasser opened this issue Jul 15, 2021 · 9 comments · Fixed by #1123

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Jul 15, 2021

Opening on the behalf of @h-joo from microsoft/TypeScript#45047:

Readonly attributes in DOMPoint, DOMMatrix, DOMRect

Some properties of DOMPoint, DOMMatrix, DOMRect became readonly, and this no
longer match the specification. This is because these types no longer override
properties from the extended types to be read/write.

Compare(DOMPoint):

Compare(DOMMatrix):

Compare(DOMRect):

Removed Types

SpeechRecognition, RTCError got removed from lib.dom.d.ts. There are existing
code which use this API, and it would be difficult to migrate without proper
type support either from the compiler or from definitelyTyped.

Offscreen Rendering API changes

OffscreenCanvas still exists, but it's marked as deprecated. Though it is no
longer a value, i.e. code calling new OffscreenCanvas no longer works, it's
just an interface. We think this might be unintentional. Though, we would still
be able to migrate via referring to the types defined in
DefinitelyTyped.

ShadowRoot interface changes

ShadowRoot is a subtype of DocumentFragment. DocumentFragment has a
getElementById which returns HTMLElement. In 4.4-beta, DocumentFragment no
longer defines its own getElementById method, meaning
HTMLElement.prototype.shadowRoot.getElementById returns Element, not
HTMLElement. This causes hundreds of breakages of code using shadowRoot.

ChildNode interface changes

In 4.4, ChildNode no longer extends Node. This seems like a bug.

DocumentOrShadowRoot interface changes

DocumentOrShadowRoot no longer has getSelection, elementFromPoint,
elementsFromPoint, caretFromRange. We also couldn't find in the repo whether
this was intentional or not.

@h-joo
Copy link

h-joo commented Jul 16, 2021

Thank you 😊

In the meanwhile we've found two more types which we missed to added to Removed Types section, which are VRDisplay and MediaStreamError.

@saschanaz
Copy link
Contributor

saschanaz commented Jul 16, 2021

Readonly attributes in DOMPoint, DOMMatrix, DOMRect

It's my fault 😬, will fix it.

Removed Types
Offscreen Rendering API changes
DocumentOrShadowRoot interface changes

Those are Chrome-only things, while SpeechRecognition is supported by Chrome and Safari but only with webkit prefix.

OffscreenCanvas seems like a good candidate for additional type package as suggested in #1023, but for now I guess it should be added to DefinitelyTyped?

SpeechRecognition miiiight be able to be added back, but I would also prefer DefinitelyTyped for this. 🤔

ShadowRoot interface changes

The current type is "correct", but since Document.getElementById is already customized for easier use, I'll do the same there.

ChildNode interface changes

It's a mixin interface implemented by some Node interfaces. The correct way to receive Nodes that can be children is ChildNode & Node, just like ParentNode & Node for Nodes that can be parents.

@h-joo
Copy link

h-joo commented Aug 24, 2021

Thank you @saschanaz and @DanielRosenwasser for the help. We've checked TS4.4-rc and I've seen much reduced breakages, and most of the remaining breakages it seems that we can fix it via DefinitelyTyped, or the use should be removed as it's vendor specific or deprecated.

Though we still see some failures with respect to removed types which are things below :

  • SpeechRecognitionEvent
  • RTCError, RTCErrorEvent

as @saschanaz mentioned that SpeechRecognitionEvent might be added to DT, I was wondering if there are any plans, I guess I can also try adding that myself.

For the RTCError, I am uncertain if it was intentional, but from this commit it seems the use of RTCErrorEvent seems to be commented out intentionally?

@saschanaz
Copy link
Contributor

as @saschanaz mentioned that SpeechRecognitionEvent might be added to DT, I was wondering if there are any plans, I guess I can also try adding that myself.

No immediate plan, you are free to do that.

For the RTCError, I am uncertain if it was intentional, but from this commit it seems the use of RTCErrorEvent seems to be commented out intentionally?

RTCError and RTCErrorEvent are excluded as they are also currently Chrome only. Maybe @types/webrtc should include them instead?

@h-joo
Copy link

h-joo commented Aug 24, 2021

Great, now all makes sense. Thank you for your help!!

@orta
Copy link
Contributor

orta commented Aug 27, 2021

Looking at DocumentOrShadowRoot losing getSelection, elementFromPoint, elementsFromPoint, caretFromRange:

  • DocumentOrShadowRoot is a mixin which is filled in by a bunch of specs
  • There are no specs from W3C which declare that DocumentOrShadowRoot should have those properties (that I've found), only Document has them (which you can see in the dom.d.ts today)

The MDN docs for ShadowRoot specifically calls these out as being red/not available in their docs, which I assume means that they have been removed in a spec, and/or browsers : https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot#methods

@saschanaz
Copy link
Contributor

Seems that elementFromPoint and elementsFromPoint should be restored since those are supported everywhere.

@andrewbranch
Copy link
Member

The red links are tooltipped as

The documentation about this has not yet been written; please consider contributing!

The browser support matrix for elementFromPoint and elementsFromPoint looks pretty complete (just IE missing support).

@Haprog
Copy link

Haprog commented Dec 13, 2021

There are no specs from W3C which declare that DocumentOrShadowRoot should have those properties (that I've found), only Document has them (which you can see in the dom.d.ts today)

This used to be declared in the Shadow DOM spec, but there's apparently some ongoing(?) work related to migrating that spec to other specs. See my related comment here: WICG/webcomponents#661 (comment)

It's weird to me that those are not anymore shown in any live spec to be part of DocumentOrShadowRoot, but to me that looks like an accident also. I'm pretty sure they were not intentionally being dropped from specs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants