Skip to content

Instantly share code, notes, and snippets.

@frankiefu
Created April 23, 2015 19:58
Show Gist options
  • Save frankiefu/23fe9b2433f47e797c63 to your computer and use it in GitHub Desktop.
Save frankiefu/23fe9b2433f47e797c63 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<script src="../../components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="x-app.html">
</head>
<body>
<x-app>
<div>Foo</div>
<div>Bar</div>
<div>Zot</div>
</x-app>
<button onclick="test()">test</button>
<script>
function test() {
document.querySelector('x-app').test();
}
</script>
</body>
</html>
<link rel="import" href="../../components/polymer/polymer.html">
<dom-module id="x-app">
<template>
<div>
<content></content>
</div>
</template>
</dom-module>
<script>
Polymer({
is: 'x-app',
test: function() {
var nodes = Polymer.dom(this).childNodes;
for (var i = nodes.length - 1; i >= 0; i--) {
Polymer.dom(this).removeChild(nodes[i]);
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment