Skip to content

Instantly share code, notes, and snippets.

@jorgehatccrma
Last active December 28, 2015 04:19
Show Gist options
  • Save jorgehatccrma/7441374 to your computer and use it in GitHub Desktop.
Save jorgehatccrma/7441374 to your computer and use it in GitHub Desktop.
Code to demonstrate a bug with polymer+jquery
<polymer-element name="gr-test">
<template>
<p>Hi there!</p>
</template>
<script>
Polymer('gr-test', {
ready: function() {
console.log("ready");
},
aMethod: function () {
console.log("calling a method");
},
});
</script>
</polymer-element>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<!-- 1. Load Polymer before any code that touches the DOM. -->
<script src="libs/polymer.min.js"></script>
<!-- 2. Load components -->
<link rel="import" href="gr-test.html">
<script type="text/javascript" src="libs/jquery-1.9.1.js"></script>
</head>
<body>
<gr-test></gr-test>
<script>
$(document).ready(function () {
var test = document.querySelector("gr-test");
console.log(test);
test.aMethod();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment