Skip to content

Instantly share code, notes, and snippets.

@jyasskin
Last active January 4, 2016 05:29
Show Gist options
  • Save jyasskin/8575145 to your computer and use it in GitHub Desktop.
Save jyasskin/8575145 to your computer and use it in GitHub Desktop.
Running on localhost, this displays "Tag Name: CXX-FUNCTION; Instance of CxxFunctionElement: false", but when copied to jsbin, it shows "Tag Name: CXX-FUNCTION; Instance of CxxFunctionElement: true". I believe 'true' is the expected result.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.1.3/platform.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.1.3/polymer.js"></script>
<polymer-element name="cxx-function" constructor="CxxFunctionElement" noscript>
<template>
<pre><code><content></content></code></pre>
</template>
</polymer-element>
<polymer-element name="cxx-section" constructor="CxxSectionElement">
<template>
<section>
Tag Name: {{tag_name}};
Instance of CxxFunctionElement: {{instance}}
<content></content>
</section>
</template>
<script>
var webComponentsReady = false;
window.addEventListener('WebComponentsReady', function() {
webComponentsReady = true;
});
Polymer('cxx-section', {
created: function() {
var self = this;
if (webComponentsReady)
this.inspectChild();
else
window.addEventListener('WebComponentsReady', function() {
self.inspectChild();
});
},
inspectChild: function() {
var child = this.firstElementChild;
this.tag_name = child.tagName;
this.instance = child instanceof CxxFunctionElement;
},
});
</script>
</polymer-element>
</head>
<body>
<cxx-section>
<cxx-function>
</cxx-function>
</cxx-section>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment