- From: Joe Pea <notifications@github.com>
- Date: Tue, 24 Oct 2017 20:14:37 +0000 (UTC)
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 24 October 2017 20:15:05 UTC
I've got a Custom Element that is used in HTML markup with existing attribute, f.e.
```html
<some-element has="...">
</some-element>
```
and in the class definition I have this:
```js
constructor( options = {} ) {
super(options)
console.log(' --- has attribute (sync)?', this.getAttribute('has')) // undefined
Promise.resolve().then(() => {
console.log(' --- has attribute (microtask)?', this.getAttribute('has')) // undefined
})
setTimeout(() => {
console.log(' --- has attribute (macrotask)?', this.getAttribute('has')) // works!
}, 0)
}
```
As you can see, I am not able to see existing attribute during construction, which seems really strange because the element already has attributes in the HTML markup, so I expected it to have attributes after calling `super()`.
Furthermore, I find it super strange that I have to defer to a _macro_ task rather than a _micro_ task to detect initial attributes.
Is this as expected?
--
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
Received on Tuesday, 24 October 2017 20:15:05 UTC