Skip to content

Process slots before processing subtree #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ let processCounter = 0;
* @return {Object} PostHTML tree
*/
function processTree(options) {
const filledSlots = {};

return (tree, messages) => {
log(`Processing tree number ${processCounter}..`, 'processTree');

Expand All @@ -176,6 +174,8 @@ function processTree(options) {
}

match.call(tree, options.matcher, currentNode => {
const filledSlots = {};

log(`Match found for tag "${currentNode.tag}"..`, 'processTree');

if (!currentNode.attrs) {
Expand Down Expand Up @@ -229,14 +229,14 @@ function processTree(options) {
return currentNode.content || nextNode.content;
});

// Process <slot> tags
processSlotContent(nextNode, filledSlots, options);

nextNode = processTree(options)(nextNode, messages);

// Process <fill> tags
processFillContent(nextNode, filledSlots, options);

// Process <slot> tags
processSlotContent(nextNode, filledSlots, options);

// Remove component tag and replace content with <yield>
currentNode.tag = false;
currentNode.content = content;
Expand Down