From 447d147df23d9afab8e7b98c6fa52d061b8dd2cf Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 10 Aug 2021 03:00:06 +0200 Subject: [PATCH] Improve void elements for xml parser --- src/dom_components/config/config.js | 3 ++- src/parser/model/ParserHtml.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dom_components/config/config.js b/src/dom_components/config/config.js index 9aa765508..a14506818 100644 --- a/src/dom_components/config/config.js +++ b/src/dom_components/config/config.js @@ -35,7 +35,8 @@ export default { */ processor: 0, - // List of void elements + // List of HTML void elements + // https://www.w3.org/TR/2011/WD-html-markup-20110113/syntax.html#void-elements voidElements: [ 'area', 'base', diff --git a/src/parser/model/ParserHtml.js b/src/parser/model/ParserHtml.js index ee9e21ee4..4e04d30a0 100644 --- a/src/parser/model/ParserHtml.js +++ b/src/parser/model/ParserHtml.js @@ -232,6 +232,11 @@ export default config => { } } + // Check for custom void elements (valid in XML) + if (!nodeChild && `${node.outerHTML}`.slice(-2) === '/>') { + model.void = true; + } + // If all children are texts and there is some textnode the parent should // be text too otherwise I'm unable to edit texnodes const comps = model.components;