aom icon indicating copy to clipboard operation
aom copied to clipboard

Consider allowing property setting through the constructor

Open domenic opened this issue 8 years ago • 2 comments

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
});

domenic avatar Aug 01 '16 10:08 domenic

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

minorninth avatar Aug 30 '16 17:08 minorninth

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.

domenic avatar Aug 30 '16 18:08 domenic