Files
web-components-workshop-dep…/index.html
2017-12-08 16:04:53 +01:00

50 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="/bower_components/custom-elements/custom-elements.min.js"></script>
<script type="text/javascript" src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
</head>
<body>
<h1>WebComponents workshop</h1>
<p>In this workshop, we will create new custom HTML Components</p>
<hello-world></hello-world>
<hello-world-with-params name="Meetup"></hello-world-with-params>
<div>
<button onclick="removeHelloWorld()">Click me to remove Hello World</button>
</div>
<div>
<input type="text" id="hello-world-param">
<button onclick="changeHelloWorldParam()">Click me to change Hello World's parameter</button>
</div>
<div>
<cat-img></cat-img>
</div>
<div>
<cat-img-fast></cat-img-fast>
</div>
<script src="src/components/hello-world.js"></script>
<script src="src/components/hello-world-with-params.js"></script>
<script src="src/components/cat-img.js"></script>
<script src="src/components/cat-img-fast.js"></script>
<script>
function removeHelloWorld(){
console.log("Called!");
const helloElement = document.getElementsByTagName("hello-world")[0];
helloElement.parentNode.removeChild(helloElement);
}
function changeHelloWorldParam(){
const helloParamElement = document.getElementsByTagName("hello-world-with-params")[0];
document.getElementsByTagName("hello-world-with-params")[0].setAttribute("name", "plop");
}
</script>
</body>
</html>