aom
aom copied to clipboard
Consider allowing property setting through the constructor
var axVirtualButton = new AccessibleNode("button");
axVirtualButton.label = "Enable Audio Descriptions";
axVirtualButton.offsetWidth = 224;
axVirtualButton.offsetHeight = 72;
could become
var axVirtualButton = new AccessibleNode("button", {
label: "Enable Audio Descriptions",
offsetWidth: 224,
offsetHeight: 72
});
I definitely like this idea.
We originally had this in a draft and deleted it simply because it's syntactic sugar and didn't seem to be necessary to get started.
We also wanted to allow for the future possibility of allowing the user to provide a function to compute some of those attributes instead, thereby deferring accessible calculation until it's needed.
var axVirtualButton = new AccessibleNode("button", { label: function() { return "Enable Audio Descriptions" }, });
Either way, I think we want to wait and bake the rest of the API first, then revisit this as a convenience
We also wanted to allow for the future possibility of allowing the user to provide a function to compute some of those attributes instead, thereby deferring accessible calculation until it's needed.
If you plan to do that eventually, you should change all of these attributes into functions ASAP, so as not to cause problems in the future. They should not be getters that hide arbitrary computation.