From 6bc41f0113b3ad21ff1bedd9877da355e4e7d629 Mon Sep 17 00:00:00 2001 From: Avi Marcus Date: Thu, 4 Feb 2016 16:30:50 +0200 Subject: [PATCH] made rt-include self closing to prevent future bugs --- src/reactTemplates.js | 5 ++++- test/data/include.rt | 3 ++- test/data/include.rt.html | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/reactTemplates.js b/src/reactTemplates.js index 25c4745..914232a 100644 --- a/src/reactTemplates.js +++ b/src/reactTemplates.js @@ -55,6 +55,8 @@ var virtualNode = 'rt-virtual'; var includeNode = 'rt-include'; var includeSrcAttr = 'src'; +var reactTemplatesSelfClosingTags = [includeNode]; + /** * @param {Options} options * @return {Options} @@ -496,7 +498,8 @@ function handleSelfClosingHtmlTags(nodes) { .map(function (node) { var externalNodes = []; node.children = handleSelfClosingHtmlTags(node.children); - if (node.type === 'tag' && _.includes(reactSupport.htmlSelfClosingTags, node.name)) { + if (node.type === 'tag' && (_.includes(reactSupport.htmlSelfClosingTags, node.name) || + _.includes(reactTemplatesSelfClosingTags, node.name))) { externalNodes = _.filter(node.children, isTag); _.forEach(externalNodes, i => i.parent = node); node.children = _.reject(node.children, isTag); diff --git a/test/data/include.rt b/test/data/include.rt index 9552782..b8b9a35 100644 --- a/test/data/include.rt +++ b/test/data/include.rt @@ -1,3 +1,4 @@
- + + test
diff --git a/test/data/include.rt.html b/test/data/include.rt.html index 8fda287..68dc1ad 100644 --- a/test/data/include.rt.html +++ b/test/data/include.rt.html @@ -1 +1 @@ -
+
test