From 8866b7e8ce723cc61edcd1c70c053b2d9b96d46e Mon Sep 17 00:00:00 2001 From: ye huping Date: Thu, 27 Apr 2017 16:54:19 +0800 Subject: [PATCH] add once keyword, not generage observe attribute for tag --- src/server/generators/tagGenerator.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/server/generators/tagGenerator.js b/src/server/generators/tagGenerator.js index 14f3bcd..3ce7697 100644 --- a/src/server/generators/tagGenerator.js +++ b/src/server/generators/tagGenerator.js @@ -19,6 +19,7 @@ export default function _tagGenerator (options = {}) { // these attributes are treated as children on the tag case 'innerHTML': case 'cssText': + case 'once': return attrsStr // these form the attribute list for this tag @@ -35,10 +36,15 @@ export default function _tagGenerator (options = {}) { // these tag types will have content inserted const closed = ['noscript', 'script', 'style'].indexOf(type) === -1 + // generate tag exactly without any other redundance attribute + const observeTag = tag.once + ? '' + : `${attribute}="true" ` + // the final string for this specific tag return closed - ? `${tagsStr}<${type} ${attribute}="true" ${attrs}/>` - : `${tagsStr}<${type} ${attribute}="true" ${attrs}>${content}` + ? `${tagsStr}<${type} ${observeTag}${attrs}/>` + : `${tagsStr}<${type} ${observeTag}${attrs}>${content}` }, '') } }