-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Instances of HTMLElement does not expose the remove() function #2910
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
Comments
I suspect this is because it is not yet part of the DOM standard and isn't yet widely supported: https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove |
@kitsonk I believe all non-IE is widely enough :-) But to be serious, many people use this, especially in extensions development because extensions are not targeted to IE. I believe it's already defacto standard, no matter if it will be standardized on W3C/whatwg or not. |
A method that exists in browsers used by developers but not in IE is exactly the kind of API that shouldn't be in lib.d.ts. If you want to opt-in to this method: interface HTMLElement {
remove(): void;
} |
Cannot understand. So you are saying TypeScript is only for IE users or only for MS? Each user can easily define most of DOM methods on This is good what you are generating dom declarations for IE, but you easily can have |
@NekR You misunderstand. We want lib.d.ts to be trustworthy and correct by default. That means you should get a list of completion results and compilation errors that match the common case. We don't want tsc to happily suggest and compile a method which then results in runtime failures on a large portion of machines running that code (whether that large portion is IE users or Chrome users or others). That means we don't want vendor prefixed items, we don't want items from the standard that aren't implemented by (m)any browsers yet, or items that are in a web browsers but not in a standard, etc. If for whatever reason you do want those things, you have an easy route to add them (as Ryan showed) and you can share any such modified lib.d.ts for others too. The alternative (requiring everyone who targets a particular platform know this problem and then go through and cleanse lib.d.ts of things that won't work for them) is much more painful and impactful. |
But you have them.
So let's say IE does not supports WebGL. Should you then include definition of it to you
I believe it's in standard, it's not a recommendation yet, but it is there. Latest published version has it: http://www.w3.org/TR/dom/
Again, I do not think non-IE is particular platform. I am not asking here about Or, one more thing. Just imagine IE will have support of |
Oh, sorry, I am wrong -- 4 of 5 implementations supports it (Opera on Presto also has it). |
@NekR, IE is not of consequence here.. we just have a script from the IE folks that makes generating and updating the library file easy. manual update has is not sustainable, we tried that :) The right thing to do is to generate the library from the dom spec at w3.org. I have filed an issue for this #3027. We would be open to taking a Pull Request for this assuming you would be interested. |
Shall we re-consider Update: it's in preview for Edge now. |
@mhegazy you should re-open this.
At this point there is no reason that we shouldn't be able to opt into typing for those methods. |
@jods4 mind filing a new issue for that. |
Instances of HTMLElement don't have access to remove function.
I'm getting the following error:
Example:
Interface ChildNode Reference
The text was updated successfully, but these errors were encountered: