diff --git a/README.md b/README.md
index a70a002..e375c0e 100644
--- a/README.md
+++ b/README.md
@@ -23,44 +23,64 @@ Components, without the addition of APIs that don't already exist.
-
-
-
+
+
+
-
- Hello World
-
-
+
-
-
-
+
+
-Tram-Deco is Cool!
+
+ Introduction
+
+This is some introductory content
+
+ More Details
+
+If you want to read more, checkout the README.
```
-[Live on Codepen](https://codepen.io/JRJurman/pen/mdYbxgw)
+[Live on Codepen](https://codepen.io/JRJurman/pen/RwXPqEe)
## How to use
@@ -92,11 +112,6 @@ Create a template tag with your component definitions, and then use Tram-Deco to
### Export JS Definition
-> [!important]
->
-> Tram-Deco import depends on `setHTMLUnsafe`, which is a recently released feature. Check
-> [caniuse.com](https://caniuse.com/?search=setHTMLUnsafe) to understand browser support and coverage here.
-
If you want to export your component definition, to be used in other projects, or to organize the components in
different files, you can do the following:
diff --git a/example/example.spec.js b/example/example.spec.js
index 5add724..67b5d6f 100644
--- a/example/example.spec.js
+++ b/example/example.spec.js
@@ -43,12 +43,6 @@ test.describe('Tram-Deco Example Components', () => {
await expect(counterB).toHaveAttribute('count', '12');
await expect(counterB.locator('button')).toHaveText('Counter: 12');
- // validate that exported components are rendered as expected
- const spoilerTag = page.locator('spoiler-tag');
- await expect(spoilerTag.locator('[aria-hidden="true"]')).toBeVisible();
- await spoilerTag.click();
- await expect(spoilerTag.locator('[aria-hidden="false"]')).toBeVisible();
-
// validate that button that implements a shadow DOM from a parent with none works as expected
const removableButton = page.locator('red-removable-button#r');
await expect(removableButton).toBeVisible();
@@ -72,5 +66,11 @@ test.describe('Tram-Deco Example Components', () => {
await expect(decrementingCounter).toHaveAttribute('count', '5');
await decrementingCounter.click();
await expect(decrementingCounter).toHaveAttribute('count', '4');
+
+ // validate that exported components work as expected
+ const introAnchor = page.locator('header-anchor#introduction');
+ await expect(introAnchor.locator('a')).toHaveAttribute('href', '#introduction');
+ const detailsAnchor = page.locator('header-anchor#more-details');
+ await expect(detailsAnchor.locator('a')).toHaveAttribute('href', '#more-details');
});
});
diff --git a/example/header-anchor.html b/example/header-anchor.html
new file mode 100644
index 0000000..60a5d12
--- /dev/null
+++ b/example/header-anchor.html
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/example/spoiler-tag.js b/example/header-anchor.js
similarity index 54%
rename from example/spoiler-tag.js
rename to example/header-anchor.js
index 2dd5c49..3fb1e23 100644
--- a/example/spoiler-tag.js
+++ b/example/header-anchor.js
@@ -3,61 +3,39 @@
class TramDeco{static processTemplate(e){[...e.content.children].forEach(e=>{TramDeco.define(e)})}static define(templateElement){const tagName=templateElement.tagName.toLowerCase();class BaseTDElement extends HTMLElement{constructor(e){var t;super(),e&&(this.attachShadow(e),(t=document.createRange()).selectNodeContents(e),this.shadowRoot.append(t.cloneContents()))}}const parentClassName=templateElement.getAttribute("td-extends"),parentClass=customElements.get(parentClassName)||BaseTDElement,modifiedConstructor=templateElement.querySelector('script[td-method="constructor"]');class TDElement extends parentClass{constructor(overrideShadowRoot){super(overrideShadowRoot||templateElement.shadowRoot),eval(modifiedConstructor?.textContent||"")}}templateElement.querySelectorAll("script[td-method]").forEach(lifecycleScript=>{const methodName=lifecycleScript.getAttribute("td-method");TDElement.prototype[methodName]=function(){eval(lifecycleScript.textContent)}}),templateElement.querySelectorAll("script[td-property]").forEach(propertyScript=>{const propertyName=propertyScript.getAttribute("td-property");Object.defineProperty(TDElement,propertyName,{get:function(){return eval(propertyScript.textContent)}})}),customElements.define(tagName,TDElement)}}
const importTemplate = document.createElement('template')
- importTemplate.setHTMLUnsafe(`
-
+ importTemplate.setHTMLUnsafe(`
+
-
-
-
-
-
+
+
-
+
`)
TramDeco.processTemplate(importTemplate);
diff --git a/example/index.html b/example/index.html
index 80da772..e6ee23c 100644
--- a/example/index.html
+++ b/example/index.html
@@ -169,8 +169,8 @@
-
-
+
+
Tram-Deco is Cool!
@@ -184,4 +184,12 @@
Import Alert
The following spoiler only works on browsers that support setHTMLUnsafe
-This is some mystery content.
+
+
+ Introduction
+
+This is some introductory content
+
+ More Details
+
+If you want to read more, checkout the README.
diff --git a/example/spoiler-tag.html b/example/spoiler-tag.html
deleted file mode 100644
index 995b929..0000000
--- a/example/spoiler-tag.html
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/package-lock.json b/package-lock.json
index 8935023..7de3d8a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "tram-deco",
- "version": "6.1.1",
+ "version": "6.1.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tram-deco",
- "version": "6.1.1",
+ "version": "6.1.2",
"license": "MIT",
"bin": {
"export-components": "scripts/export-components.js"
diff --git a/package.json b/package.json
index bc5c7b5..b8f74b5 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "tram-deco",
- "version": "6.1.1",
+ "version": "6.1.2",
"description": "Declarative Custom Elements using native Web Component APIs and specs",
"main": "tram-deco.js",
"files": [
@@ -15,7 +15,7 @@
"start": "serve . -p 3000",
"prepublishOnly": "npm run build",
"build": "uglifyjs tram-deco.js -o tram-deco.min.js -c -m",
- "test-export": "node scripts/export-components.js example/spoiler-tag.html -o example/spoiler-tag.js",
+ "test-export": "node scripts/export-components.js example/header-anchor.html -o example/header-anchor.js",
"pretest": "npm run build && npm run test-export",
"test": "playwright test --ui",
"test:ci": "playwright test"