Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions packages/cli/test/functional/test_site/expected/siteData.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@
},
"headingKeywords": {}
},
{
"src": "testPanels.md",
"title": "Test: Panels",
"headings": {},
"headingKeywords": {}
},
{
"src": "testPanelMarkdownParsing.md",
"title": "markdown-it should parse minimized panel as inline element and normal panel as block element",
Expand Down
263 changes: 263 additions & 0 deletions packages/cli/test/functional/test_site/expected/testPanels.html

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/cli/test/functional/test_site/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
"src": "testIncludeBoilerplate.md",
"title": "Content inside <include> should not be processed by markdown"
},
{
"src": "testPanels.md",
"title": "Test: Panels"
},
{
"src": "testPanelMarkdownParsing.md",
"title": "markdown-it should parse minimized panel as inline element and normal panel as block element"
Expand Down
25 changes: 25 additions & 0 deletions packages/cli/test/functional/test_site/testPanels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**Panel with attributes**

<panel header="Correct header">
Lorem ipsum...
</panel>

<br>

**Panel with slots**

<panel>
<span slot="header">Correct header</span>
Lorem ipsum...
</panel>

<br>

**Panel with slots overriding attributes**

<panel header="Should not appear: Overwritten header">
<span slot="header">Correct header</span>
Lorem ipsum...
</panel>

<br>
4 changes: 3 additions & 1 deletion packages/core/src/html/MdAttributeRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class MdAttributeRenderer {

processPanelAttributes(node) {
this.processAttributeWithoutOverride(node, 'alt', false, '_alt');
this.processAttributeWithoutOverride(node, 'header', false);
if (!this.hasSlotOverridingAttribute(node, 'header')) {
this.processAttributeWithoutOverride(node, 'header', false);
}
}

/*
Expand Down
18 changes: 18 additions & 0 deletions packages/core/test/unit/html/NodeProcessor.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ module.exports.PROCESS_PANEL_ATTRIBUTES_EXPECTED = `
</panel>
`;

module.exports.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY = `
<panel header="# Lorem ipsum">
<div slot="header">
This existing header slot should be preserved in favour over header attribute, with a logger warning for repeated attributes.
</div>
Header attribute should be ignored and deleted while header slot is reserved.
</panel>
`;

module.exports.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
<panel>
<template #header><div>
This existing header slot should be preserved in favour over header attribute, with a logger warning for repeated attributes.
</div></template>
Header attribute should be ignored and deleted while header slot is reserved.
</panel>
`;

module.exports.PROCESS_PANEL_HEADER_NO_OVERRIDE = `
<panel header="# Lorem ipsum" alt="**strong alt**">
<div slot="header">
Expand Down
2 changes: 2 additions & 0 deletions packages/core/test/unit/html/NodeProcessor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const processAndVerifyTemplate = (template, expectedTemplate, postProcess = fals
test('processNode processes panel attributes and inserts into dom as slots correctly', () => {
processAndVerifyTemplate(testData.PROCESS_PANEL_ATTRIBUTES,
testData.PROCESS_PANEL_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY,
testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_NO_OVERRIDE,
testData.PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED);
});
Expand Down