I have seen statements like below in many D3 examples. However, I can't find out what it means. In particular, I don't know what this self
variable refers to. Additionally, does this manifest some sort of D3 magic/convention or is it just an ad-hoc thing? Thank you very much.
d3.select(self.frameElement).style("height", height + "px");
BTW, here is the example where I copied the above statement.
self
: if not redefined (typically as copy of this
) than it is window
object which always points to window
. So they can be used interchangeably.
window.frameElement
: Returns the element (such as <iframe> or <object>) in which the window is embedded, or null if the window is top-level.
See Window.frameElement
On this example I found the following comment:
// Hack to make this example display correctly in an iframe on bl.ocks.org
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With