-
Notifications
You must be signed in to change notification settings - Fork 83
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
Deprecate some DOM methods? #31
Comments
👍 I think |
I'm moderately fond of those methods because I have a general aversion to string interpolation where it can be avoided — so that DOM.canvas(width, 500) ...feels a little better than html`<canvas width="${width}" height="500"></canvas>` ... but I certainly see your point. Yes, we should deprecate them by removing the documentation — but it seems like there's no harm in leaving the actual methods around. |
You can shorten it slightly… html`<canvas width=${width} height=500>` |
Could we salvage the Edit: I put it here for personal usage |
DOM.svg came up as an unnecessary impediment to adapting D3 examples to vanilla JavaScript. Other than require, DOM.svg is the only stdlib method used by most of the D3 examples. And it’s trivial to replace d3.select(DOM.svg(width, height)) with d3.create("svg").attr("viewBox", [0, 0, width, height]) which is (sufficiently) equivalent. This, to me, is strong evidence that we should make the standard library as small as possible. |
I believe DOM.element is still relevant, as it facilitates attribute composition and escaping. Some of the issues with template strings are outlined here: https://observablehq.com/@mootari/attribute-escaping-in-template-strings That being said, personally I could survive on |
Yes, I want to switch our |
Proposed: we deprecate the following methods in favor of the html or svg tagged template literal.
None of these methods are especially helpful, so I think it’s pretty much always more idiomatic to use literal HTML. By deprecating, I mean these methods would continue to be supported in the standard library, but we would remove their documentation from the README, or at least relegate them to a deprecated section.
(That leaves DOM.context2d, DOM.download, DOM.uid, for those keeping score.)
The text was updated successfully, but these errors were encountered: