From afbe59e2b87b3d2cc6ebd2f227cea79c28ebf01f Mon Sep 17 00:00:00 2001 From: ahacad Date: Thu, 15 Jul 2021 16:30:34 +0800 Subject: [PATCH] fix(mdast): fix mdast attributes attributes now appear even when there is no note/warning --- mdast-util-details/index.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/mdast-util-details/index.js b/mdast-util-details/index.js index 05147c7..ca2f444 100644 --- a/mdast-util-details/index.js +++ b/mdast-util-details/index.js @@ -19,28 +19,11 @@ function enterContainer(token) { enter.call(this, 'detailsContainer', token, 'details'); } function enterSummary(token) { - enter.call(this, 'detailsContainerSummary', token, 'summary'); -} - -function enter(type, token, name) { - this.enter( - { type: type, name: name || '', attributes: {}, children: [] }, - token, - ); -} - -function exitExpanded(token) { - this.setData('detailsAttributes', []); - this.getData('detailsAttributes').push(['open', true]); -} -function exitClassName(token) { - this.getData('detailsAttributes').push(['class', this.sliceSerialize(token)]); - + // pushin all the attributes for
tag before entering tag const attributes = this.getData('detailsAttributes'); const cleaned = {}; let index = -1; let attribute; - // pushin all the attributes while (++index < attributes.length) { attribute = attributes[index]; if (attribute[0] === 'class' && cleaned.class) { @@ -52,6 +35,22 @@ function exitClassName(token) { this.setData('detailsAttributes'); this.stack[this.stack.length - 1].attributes = cleaned; + + enter.call(this, 'detailsContainerSummary', token, 'summary'); +} +function enter(type, token, name) { + this.enter( + { type: type, name: name || '', attributes: {}, children: [] }, + token, + ); +} + +function exitExpanded(token) { + this.setData('detailsAttributes', []); + this.getData('detailsAttributes').push(['open', true]); +} +function exitClassName(token) { + this.getData('detailsAttributes').push(['class', this.sliceSerialize(token)]); } function exit(token) { this.exit(token);