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

HTMLOrSVGElement does not extend Element #41529

Closed
MarsiBarsi opened this issue Nov 13, 2020 · 7 comments
Closed

HTMLOrSVGElement does not extend Element #41529

MarsiBarsi opened this issue Nov 13, 2020 · 7 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript
Milestone

Comments

@MarsiBarsi
Copy link

MarsiBarsi commented Nov 13, 2020

TypeScript Version: any

Expected behavior:
HTMLOrSVGElement extends Element

Actual behavior:
it does not

Playground Link: https://www.typescriptlang.org/play?ts=4.2.0-dev.20201112#code/DYUwLgBAhgXBASAVAsgGQPICcDKA1A4gKKgC2IAdmANwBQokARnMSGZbTQxALzRVA

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Nov 13, 2020
@RyanCavanaugh
Copy link
Member

This is correct; Element lacks some things that are in both HTMLElement and SVGElement

@MarsiBarsi
Copy link
Author

Thank you for answer, @RyanCavanaugh!
Sure. My proposal is to extend HTMLOrSVGElement with Element because both HTMLElement and SVGElement are actually Element

@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Nov 13, 2020

The interface describes the common properties between HTMLElement and SVGElement. It's still not safe to assign an arbitrary Element to that

If you have DogOrCat, you still can't assign a Mammal to it, because there are Mammals that aren't Dogs or Cats even though both of those are Mammals. This would only be valid if you could prove that there are no other Mammals except Dog or Cat, but this isn't the case.

@waterplea
Copy link

@RyanCavanaugh I believe you are confused because playground link is incorrect example. With your example of DogOrCat interface and MammalDogOrCat IS a Mammal therefore DogOrCat should extend Mammal. Right now, say, if Mammal interface has milk property, DogOrCat interface doesn't have it, although it should.

@RyanCavanaugh
Copy link
Member

I don't disagree, but the example provided attempts to assign an Element to an HTMLOrSVGElement, which still shouldn't be allowed.

@MarsiBarsi
Copy link
Author

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript and removed Working as Intended The behavior described is the intended behavior; this is not a bug labels Nov 13, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Nov 13, 2020
@ExE-Boss
Copy link
Contributor

The current behaviour is correct, because HTMLOrSVGElement is an interface mixin:

interface mixin HTMLOrSVGElement {
  [SameObject] readonly attribute DOMStringMap dataset;
  attribute DOMString nonce; // intentionally no [CEReactions]

  [CEReactions] attribute boolean autofocus;
  [CEReactions] attribute long tabIndex;
  undefined focus(optional FocusOptions options = {});
  undefined blur();
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants