mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
made rt-include self closing to prevent future bugs
This commit is contained in:
parent
9d38cbb828
commit
6bc41f0113
@ -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);
|
||||
|
@ -1,3 +1,4 @@
|
||||
<div>
|
||||
<rt-include src="className.rt"/>
|
||||
<rt-include src="className.rt">
|
||||
<span>test</span>
|
||||
</div>
|
||||
|
@ -1 +1 @@
|
||||
<div><div class="a"></div></div>
|
||||
<div><div class="a"></div><span>test</span></div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user