From 6dc37f652a37d676c27f9c04de1218b4ec5de5ca Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 21 Jun 2018 02:07:53 +0200 Subject: [PATCH] Detect when the node has already a type defined --- src/parser/model/ParserHtml.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/parser/model/ParserHtml.js b/src/parser/model/ParserHtml.js index d2fd70fa6..7c3937040 100644 --- a/src/parser/model/ParserHtml.js +++ b/src/parser/model/ParserHtml.js @@ -71,15 +71,22 @@ module.exports = config => { // Start with understanding what kind of component it is if (ct) { let obj = ''; + let type = + node.getAttribute && node.getAttribute(`${modelAttrStart}type`); - // Iterate over all available Component Types and - // the first with a valid result will be that component - for (let it = 0; it < ct.length; it++) { - obj = ct[it].model.isComponent(node); - if (obj) break; - } + // If the type is already defined, use it + if (type) { + model = { type }; + } else { + // Iterate over all available Component Types and + // the first with a valid result will be that component + for (let it = 0; it < ct.length; it++) { + obj = ct[it].model.isComponent(node); + if (obj) break; + } - model = obj; + model = obj; + } } // Set tag name if not yet done