@muonic/muon 0.0.2-beta.34 → 0.0.2-beta.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-beta.35](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.34...v0.0.2-beta.35) (2023-08-03)
6
+
5
7
  ### [0.0.2-beta.34](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.33...v0.0.2-beta.34) (2023-08-02)
6
8
 
7
9
 
@@ -106,7 +106,11 @@ export const MuonElementMixin = (superClass) => class extends superClass {
106
106
  }
107
107
 
108
108
  render() {
109
- return html`${this[`${this.type}Template`]}`;
109
+ if (this[`${this.type}Template`]) {
110
+ return html`${this[`${this.type}Template`]}`;
111
+ }
112
+
113
+ return html`${this.standardTemplate}` || html``;
110
114
  }
111
115
  };
112
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-beta.34",
3
+ "version": "0.0.2-beta.35",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -45,7 +45,7 @@ export default (name, el, prefix = process.env.MUON_PREFIX) => {
45
45
 
46
46
  const dynamicArgs = (args) => {
47
47
  const dArgs = args && Object.keys(args).map((arg) => {
48
- if (arg === 'text') {
48
+ if (!el.observedAttributes?.includes(arg)) {
49
49
  return undefined;
50
50
  }
51
51
 
@@ -68,3 +68,23 @@ snapshots["card standard with image"] =
68
68
  `;
69
69
  /* end snapshot card standard with image */
70
70
 
71
+ snapshots["card standard fallback"] =
72
+ `<div class="card">
73
+ <div class="body">
74
+ <div class="header">
75
+ <slot name="header">
76
+ </slot>
77
+ </div>
78
+ <div class="content">
79
+ <slot>
80
+ </slot>
81
+ </div>
82
+ <div class="footer">
83
+ <slot name="footer">
84
+ </slot>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ `;
89
+ /* end snapshot card standard fallback */
90
+
@@ -46,6 +46,35 @@ describe('card', async () => {
46
46
  expect(shadowRoot.querySelector('.media')).to.be.null; // eslint-disable-line no-unused-expressions
47
47
  });
48
48
 
49
+ it('standard fallback', async () => {
50
+ const cardElement = await fixture(html`
51
+ <${tag} type="unknown-type-does-not-exist">
52
+ <h2 slot="header">Heating services</h2>
53
+ <p>Product and services we offer for energy in your home</p>
54
+ <div slot="footer">Footnote</div>
55
+ </${tag}>`);
56
+ await defaultChecks(cardElement);
57
+
58
+ const shadowRoot = cardElement.shadowRoot;
59
+
60
+ const headerSelector = shadowRoot.querySelector('.header');
61
+ expect(headerSelector).to.not.be.null; // eslint-disable-line no-unused-expressions
62
+ const header = headerSelector.querySelector('slot[name="header"]');
63
+ expect(header.assignedElements()[0].textContent).to.equal('Heating services', 'Heading slot value matches');
64
+
65
+ const content = shadowRoot.querySelector('.content');
66
+ expect(shadowRoot.querySelector('.content')).to.not.be.null; // eslint-disable-line no-unused-expressions
67
+ const paragraph = content.querySelector('slot');
68
+ expect(paragraph.assignedElements()[0].textContent).to.equal('Product and services we offer for energy in your home', 'Content slot value matches');
69
+
70
+ const footerSelector = shadowRoot.querySelector('.footer');
71
+ expect(footerSelector).to.not.be.null; // eslint-disable-line no-unused-expressions
72
+ const footer = footerSelector.querySelector('slot[name="footer"]');
73
+ expect(footer.assignedElements()[0].textContent).to.equal('Footnote', 'Footer slot value matches');
74
+
75
+ expect(shadowRoot.querySelector('.media')).to.be.null; // eslint-disable-line no-unused-expressions
76
+ });
77
+
49
78
  it('standard with image', async () => {
50
79
  const cardElement = await fixture(html`
51
80
  <${tag} image="tests/components/image/images/150.png" alt="image alt">