-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy-element.html
89 lines (85 loc) · 1.91 KB
/
my-element.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<link rel="import" href="bower_components/polymer/polymer-element.html">
<link rel="import" href="bower_components/polymer/lib/mixins/gesture-event-listeners.html">
<script src="/Bindable.js"></script>
<link rel="import" href="my-element2.html">
<dom-module id="my-element">
<template>
<style>
#testDynamic {
width: 100px;
height: 50px;
background: #856ce2;
border-radius : 10px;
text-align : center;
color : white;
display : flex;
flex-direction : columns;
align-items: center;
}
#testDynamic p{
width : 100%;
}
#content{
height : 1000px;
width : 200px;
}
#good{
width : 50%;
height : 250px;
}
#good{
width : 45%;
height : 250px;
float : left;
}
#testing{
width : 45%;
float : left;
height : 250px;
}
</style>
<div id="good">
<p>Static Element 2 : </p>
<my-element2 msg="{{msg}}" prop="{{prop}}"></my-element2>
</div>
<div id="testing">
<p>Dynamic Element : </p>
<div id="testDynamic" on-tap="testDynamic"><p>Create !</p></div>
<div id="content"></div>
</div>
</template>
<script>
class MyElement extends Bindable(Polymer.GestureEventListeners(Polymer.Element)) {
static get is() {
return 'my-element';
}
static get properties() {
return {
msg: {
type: String,
value : "This should not be displayed",
notify: true
},
prop : {
type : Object,
value : {
test : "This should not be displayed neither"
},
notify : true
}
}
}
testDynamic() {
var element = document.createElement("my-element2");
for (var i = 0; i < this.$.content.children.length; i++) {
this.$.content.children[i].remove();
}
this._bind("msg", element);
this._bind("prop", element);
this._bind("prop.test", element);
this.$.content.appendChild(element);
}
}
customElements.define(MyElement.is, MyElement);
</script>
</dom-module>