Skip to content

Instantly share code, notes, and snippets.

@notwaldorf
Last active August 29, 2015 14:26
Show Gist options
  • Save notwaldorf/44da856a3debdc8ab289 to your computer and use it in GitHub Desktop.
Save notwaldorf/44da856a3debdc8ab289 to your computer and use it in GitHub Desktop.
No `offsetParent` in the `attached` callback in Chrome
<!doctype html>
<html lang="en">
<head>
<title>offset parent demo</title>
<link rel="import" href="some-thing.html">
</head>
<body>
<some-thing></some-thing>
</body>
</html>
<link rel="import" href="../../polymer/polymer.html">
<dom-module id="some-thing">
<template>
<div>hi</div>
</template>
<script>
Polymer({
is: 'some-thing',
attached: function() {
console.log(window.getComputedStyle(this.parentNode).position);
console.log(this.offsetParent);
}
})
</script>
</dom-module>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="import" href="../../polymer/polymer.html">
<script>
var proto = Object.create(HTMLElement.prototype);
proto.attachedCallback = function() {
//if (!this.offsetParent) {
console.log(window.getComputedStyle(this.parentNode).position);
console.log(this.offsetParent);
//}
};
proto.createdCallback = function() {
console.log('hi');
};
document.registerElement('a-thing', {prototype:proto});
</script>
</head>
<body>
<a-thing></a-thing>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment