-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtextComponent.js
More file actions
executable file
·39 lines (28 loc) · 867 Bytes
/
Copy pathtextComponent.js
File metadata and controls
executable file
·39 lines (28 loc) · 867 Bytes
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
function updateText(){
if(!this.element){
return;
}
var value = this.text();
this.element.data = (value == null ? '' : value);
}
function autoRender(content){
this.element = document.createTextNode(content);
}
function autoText(text, fastn, content) {
text.render = autoRender.bind(text, content);
return text;
}
function render(){
this.element = this.createTextNode(this.text());
this.emit('render');
};
function textComponent(fastn, component, type, settings, children){
component.createTextNode = textComponent.createTextNode;
component.render = render.bind(component);
component.setProperty('text', fastn.property('', updateText.bind(component)));
return component;
}
textComponent.createTextNode = function(text){
return document.createTextNode(text);
};
module.exports = textComponent;