forked from JanMiksovsky/polymer-micro-test
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-element.html
More file actions
52 lines (43 loc) · 1.75 KB
/
test-element.html
File metadata and controls
52 lines (43 loc) · 1.75 KB
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
<!--
Sample web component created using polymer-micro and a small set of helpers.
-->
<!-- Note use of polymer-micro instead of full Polymer. -->
<link rel="import" href="bower_components/polymer/polymer-micro.html">
<!-- Note that we can use a real template, not a dom-module. -->
<template id="test-element">
Hello, <content></content><span id="punctuation">.</span>
</template>
<script>
// polymer-micro supplies a slimmed-down version of the Polymer class factory.
Polymer({
// Since polymer-micro supports Polymer behaviors, we can mix in the
// additional features we want as a behavior.
behaviors: [MinimalComponent],
is: 'test-element',
// polymer-micro supports marshalling of attributes to properties.
properties: {
punctuation: {
type: String
}
},
// Expose the punctuation as a property/attribute.
// This property is data-bindable, but the internal implementation itself
// doesn't rely on the data binding feature from the full Polymer.
get punctuation() {
return this.$.punctuation.textContent;
},
set punctuation(value) {
if (this.$.punctuation.textContent !== value) {
this.$.punctuation.textContent = value;
// Fire a change event for Polymer-compatible data binding.
// TODO: We may need to add a 'value' property to the event details.
this.dispatchEvent(new CustomEvent('punctuation-changed'));
}
},
// The component can supply a reference to its own template. This reference
// is grabbed at the point this file is imported (as an HTML Import). The
// "currentImport" global is defined by Polymer. Here we use it to scan
// through this document and find the template element at the top of the file.
template: currentImport.querySelector('#test-element')
});
</script>