Skip to content

Google Feedback on 4.4 Beta #1067

Closed

Description

Opening on the behalf of Hana Joo (@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.

Activity

  1. h-joo commented on Jul 16, 2021

    @h-joo

    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.

  2. saschanaz commented on Jul 16, 2021

    @saschanaz
    Contributor

    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.

  3. h-joo commented on Aug 24, 2021

    @h-joo

    Thank you Kagami Sascha Rosylight (@saschanaz) and Daniel Rosenwasser (@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 Kagami Sascha Rosylight (@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?

  4. saschanaz commented on Aug 24, 2021

    @saschanaz
    Contributor

    as Kagami Sascha Rosylight (@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?

  5. h-joo commented on Aug 24, 2021

    @h-joo

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

  6. orta commented on Aug 27, 2021

    @orta
    Contributor

    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

  7. saschanaz commented on Aug 27, 2021

    @saschanaz
    Contributor

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

  8. andrewbranch commented on Aug 27, 2021

    @andrewbranch
    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).

  9. Haprog commented on Dec 13, 2021

    @Haprog

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions