Consider following code:
(function () {
'use strict';
delete document.body.dataset.state;
})();
where body dataset
is empty. Safari treats all DOMStringMap values — well, I guess so — as ReadOnly
, and their enumerable
, configurable
and writable
descriptor values are all set to false
. This causes the TypeError: Unable to delete property
to appear in the mentioned above example.
But in Chrome dataset property descriptor values are set to true
(can be checked with Object.getOwnPropertyDescriptor()
), and deleting inexistent attribute does not throw the error.
So, what behavior is correct? The spec says about readonly dataset, but writable DOMStringMap, so I assume dataset properties must be deletable. Am I missing something?