How to get custom element width from script element?
<polymer-element name="his-elem">
<div>
blah
</div>
</polymer-element>
@CustomTag('his-elem')
class blah extends PolymerElement {
@override
void attached() {
// how do I get the <his-elem> width (just width, no padding border stuff) here?
// document.querySelector('his-elem').getComputedStyle().width gives me "auto"...
}
}
Update
Add :host {display: block;}to your element, then you can get the actual width with <his-elem>.clientWidth.
source
share