Re: [whatwg/dom] Attributes not ready on element construction? (#522)

That's what I was going to test next. But, I think it will work fine. If an attribute is already detected to exist, then it doesn't set the default value. If the Attribute is detected not to exist then it sets the default value. So I don't think it will break imperatively.

You will do one of the following

1. Construct the element and never set the attribute.
   - The default value will be set in a future macrotask.
1. Construct the element and synchronously set the attribute.
   - in a future macrotask this is detected and no default value is set.
1. Construct the element and asynchronously set the attribute in a following microtask.
   - in a future macrotask this is detected and no default value is set.
1. Construct the element and asynchronously set the attribute in a future macrotask.
   - if my future macrotask runs before yours no default attribute is detected so one is set, then your task sets the attribute later and my `attributeChangedCallback` handles this fine, destroying previous state and setting new state.
   - if my future macrotask runs after yours, then then your attribute is detected and no default is set.

I'm using a simple conditional check to see if the attribute exists, if not I set it. And the attributeChangedCallbak otherwise handles everything fine.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/522#issuecomment-339378439

Received on Wednesday, 25 October 2017 15:55:10 UTC