hedera-web/js/vn/compiler-text.js

34 lines
669 B
JavaScript
Raw Normal View History

2022-06-18 21:04:34 +00:00
const Compiler = require('./compiler');
/**
* Compiles a @Text from text node.
*/
module.exports = new Class({
Extends: Compiler
,compile: function(builder, node, tagName) {
if (tagName && tagName != 't')
return null;
const text = node.textContent;
const context = {text};
if (tagName === 't') {
context.text = _(node.firstChild.textContent);
} else if (this.isExpr(text, true)) {
context.text = '';
this.compileExpr(context, null, text, true);
}
return context;
}
,instantiate: function(doc, context) {
return doc.createTextNode(context.text);
}
,setProperty(object, property, value) {
object.textContent = value;
}
});