-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-text-extractor.html
More file actions
70 lines (55 loc) · 1.67 KB
/
basic-text-extractor.html
File metadata and controls
70 lines (55 loc) · 1.67 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!--
Exposes the text of its own content as an attribute which can be bound to.
Elements often need to convert the content of distributed nodes into a value
which can be passed to an *attribute* on another element via binding. This
element makes that possible in a declarative fashion. For example, suppose an
element wants to pass its own distributed content to a sub-element called
interesting-element:
<polymer-element name="sample-element" noscript>
<template>
<basic-text-extractor value="{{foo}}">
<content></content>
</basic-text-extractor>
<interesting-element value="{{foo}}"></interesting-element>
</template>
</polymer-element>
This element effectively lets one bind to the text of a content element. If the
distributed content itself contains content elements, these will be recursively
traversed in document order.
@element basic-text-extractor
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../basic-shared/basic-shared.html">
<dom-module id="basic-text-extractor">
<template>
<style>
/* Hide this element unless the .show class is applied. */
:host(:not(.show)) {
display: none;
}
</style>
<content id="content"></content>
</template>
</dom-module>
<script>
Polymer({
behaviors: [Basic.ContentChanged],
contentChanged: function() {
this.value = this.flattenTextContent.trim();
},
is: 'basic-text-extractor',
properties: {
/**
* The flattened text, including text in distributed content.
* White space will be trimmed from the result.
*
* @attribute value
*/
value: {
notify: true,
type: String,
value: undefined
}
}
});
</script>