I have four Polymer elements A-A, B-1, B-2, and X-X with X-X including A-A and B-1. B-1 is including B-2. The height of A-A should determine the height of B-2. I get the height of AA via the script this.$.A-A.offsetHeight;
- so far so good.
But how do I programmatically (via script) change element’s B-2 height?
Even better would be to change the height of .myB2class
in element B-2.
Element X-X
<polymer-element name="X-X" on-click="{{getHeight}}">
<template>
<style>
:host {
display:block;
}
</style>
<A-A></A-A>
<B-1></B-1>
</template>
<script>
(function () {
Polymer('X-X', {
getHeight: function() {
var heightAA = this.$.A-A.offsetHeight;
console.log(height);
}
});
})();
</script>
</polymer-element>
Partially succeeding...
After trying everything what Google threw back at me, I'm happy that at least this piece outputs something other than null:
var B2 = document.querySelectorAll("B-2::shadow .myB2class");
...more precisely console returns:
[div#x.flext-content-story-body, item: function, array: function]
› 0: div#x.flext-content-story-body
length: 1
› __proto__: NodeList
BUT, trying to set the height via .style.height = heightAA;
returns undefined (same with static value "100px"). Oh, and then reading something like this is just to good to be true (tried it, no reaction, nada, no error, no output):
You can dynamically change an element’s styling by, you guessed it, modifying its .style property.
From the outside:
var xFoo = document.createElement('x-foo');
xFoo.style.background = 'blue'; [e.g. xFoo.style.height = '100px']
I'm probably just overseeing a tiny detail so please, feel free to jump in.