Simplifying literal merging code
This commit is contained in:
parent
e362a54551
commit
dd6eac2b4e
@ -18,6 +18,11 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
merge(other) {
|
||||
this.textValue += other.textValue;
|
||||
this.literal.textValue += other.literal.textValue;
|
||||
},
|
||||
|
||||
setup() {
|
||||
this.literal = this.properties.literal;
|
||||
}
|
||||
|
@ -68,10 +68,8 @@ export default {
|
||||
this.parts = _.reduce(this.properties.parts.elements, function(result, node) {
|
||||
var last = _.last(result);
|
||||
|
||||
if (last && node.elements[0].type === 'literal' && node.elements[1].textValue === '' && last.elements[0].type === 'literal' && last.elements[1].textValue === '') {
|
||||
last.textValue += node.textValue;
|
||||
last.elements[0].textValue += node.elements[0].textValue;
|
||||
last.elements[0].literal.textValue += node.elements[0].literal.textValue;
|
||||
if (last && node.canMerge && last.canMerge) {
|
||||
last.elements[0].merge(node.elements[0]);
|
||||
} else {
|
||||
result.push(node);
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ export default {
|
||||
|
||||
setup() {
|
||||
this.content = this.properties.content;
|
||||
this.canMerge = (this.elements[0].type === 'literal' && this.elements[1].textValue === '');
|
||||
|
||||
if (this.properties.repeat.textValue !== '') {
|
||||
this.repeat = this.properties.repeat;
|
||||
|
Loading…
Reference in New Issue
Block a user