Paper Cuts in the Web Platform
As with any large system built by a many contributors over many years, the Web Platform has many small mistakes, inconsistencies, irritating behaviors, and missing features. In smaller scale systems these bits of technical debt accumulate over time and some are occasionally even fixed.
Unfortunately due to the requirement of backwards compatibility, many of the things that bother me about building on the web can never be fixed or changed.
This post is a place for me to vent list the changes I might make if I could.
They're loosely categorized, in no particular order, and entirely lacking context. Maybe someday I'll link each of them to their own explanation post (no promises). There's a very good chance that you will disagree with some or all of these changes, so by all means write your own list or write a response explaining why the way things are Is Good Actually™.
HTML
-
<a>should be<link> -
All elements should be able to be self-closing, and all self-closing elements should include a
/ -
<img>elements should have acontrolsattribute -
<style>elements should have asrcattribute -
<table>elements should have asrcattribute -
aria-labelforshould exist, and field elements (<input>,<select>,<textarea>) should have alabelattribute. -
hrefandsrcattributes should be renamed tourl -
<source>elements should fall back when the linked source produces an error -
<input>should not exist and we should instead have dedicated elements for each of the input types -
<option>should support rich content -
Classes and other space-separated lists should use any unicode whitespace character as a separator
-
<iframe>should be able to haveheight: autoto expand vertically -
<textarea>should be able to haveheight: autoto expand vertically -
<area>'scoordsattribute should use explicit units, and the unitless coordinates should be relative to the image's native coordinate space so that image maps can be responsive -
<summary>should just be<button>, or<label> -
<legend>should just be<label> -
<figcaption>should just be<label> -
<section>should be able to receive an accessible name from<label> -
<h1>-<h6>should be<h>with an optionallevelattribute -
<head>and<body>are entirely unnecessary. Just put everything directly in<html> -
<samp>and<var>are unnecessary -
<time>should automatically format time strings and allow visitors to see the time in their local timezone
CSS
-
@layershould override non-layered styles, or non-layered styles should be part of adefaultlayer with a reserved name that can be ordered among the layers -
<fieldset>should have normal styles, and not the weird overlapping border behavior -
:linkshould match:any-link
JS
-
Datesucks and should go away (Someday we'll be able to use Temporal) -
Blocks should have been able to be evaluated as expressions
-
throwshould be an expression -
for,while, anddoloops should have anelsecondition -
loopshould exist for infinite loops -
switchshouldbreakimplicitly, and usecontinueto trigger fall-through in the rare case where it's desirable -
ClassList,Storage, and otherSet-like APIs should all use a common interface -
The standard library should be versioned and imported
-
Field Validation API sucks
- invalid event is inconsistent
- submit event is inconsistent
- validation event is missing
:invalidapplies before fields are dirty:user-invalidlacks an API to force a field to be dirty- field dirty state isn't exposed
setCustomValidityonly accepts strings- native validation messages use popovers which conflict with autocomplete
- native validation messages don't include a declarative API that can be used to override/translate the messages
-
DocumentFragmentnodes should be mountable, or we should have aVirtualFragmentnode of some sort -
DOM nodes should have a smaller API surface area by preferring composition over inheritance
-
All DOM events should bubble
-
Events should default to
bubblephase instead ofcapture -
All Observers should follow the same common interface
-
DOM API needs declarative way to build HTML without rebuilding existing HTML
-
History API Sucks (Someday we'll be able to use the Navigation API)
popstateevent is inconsistent and should have been some sort ofstatechangeevent that is always triggered when transitioning- Get rid of the unused second parameter on
pushStateandreplaceState
-
nullshould exist;undefinedshould not. -
The
%operator should only return positive values -
geolocation.getCurrentPositionshould return aPromise -
Field elements need an undo/redo API
-
List-like objects (
DOMRectList,NodeList,FileList, etc) should be readonly arrays -
DOM nodes should be constructable via constructors instead of
document.create*methods -
Intl.DateTimeFormat.prototype.formatToPartsshould return an object instead of an array -
Generators should have a way to access the value passed into
nextthe first timenextis called
SVG
-
<circle>and<ellipse>should usexandyinstead ofcxandcy -
Strokes should have some sort of
stroke-alignstyle to be able to shift the stroke to the left or right of the guideline
