-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
What is the issue with the HTML Standard?
The canvas TextStyles section says that for the direction IDL attribute "The direction IDL attribute, on getting, must return the current value." This is not currently interoperable when the value is "inherit", the default.
Firefox seems to follow the spec, reporting "inherit", but Chrome and Safari both resolve the "inherit" value to either "ltr" or "rtl" and report the resolved value.
The question here is which result is more useful for web developers. Knowing what the actual value is helps you know how it might change as other things in the page change (such as the direction CSS property or the HTML dir attribute), but to actually figure out the used value you would need to do a lot of work yourself. On the other hand, reporting the used value tells you what the test is going to render as, but tells you nothing of where the value came from (and doesn't even round-trip).
The underlying issue is that, unlike in CSS, there is no distinction between "the value" and "the computed value". I also have no idea how much content would break if the behavior was changed, although I'll add a counter to Chrome in an attempt to find out how often "ltr" or "rtl" is reported instead of "inherit" (i'm guessing a lot).
Resolution of this issue would clarify which of the two results is actually the right one, and optionally come up with a way for developers to say which one they want.
<!DOCTYPE html>
<html>
<body>
<div>
<canvas id="en" width="200px" height="100px"></canvas>
</div>
<script>
let en_context = document.getElementById("en").getContext("2d");
en_context.direction = "inherit";
let text = "Hello";
en_context.color = "black";
en_context.fillText(text, 50, 25);
console.log(en_context.direction);
</script>
</body>
</html>