@teleporthq/teleport-component-generator-html 0.42.0 → 0.42.10

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.
@@ -19,3 +19,80 @@ describe('declares a propDefinitions with type object and use it', () => {
19
19
  expect(htmlFile?.content).toContain('teleportHQCluj')
20
20
  })
21
21
  })
22
+
23
+ describe('data-node-id attribute support', () => {
24
+ test('adds data-node-id to HTML elements when explicitly set in attrs', async () => {
25
+ const generator = createHTMLComponentGenerator()
26
+ const testComponent = component(
27
+ 'TestComponent',
28
+ elementNode('container', { 'data-node-id': { type: 'static', content: 'my-custom-id' } })
29
+ )
30
+ const result = await generator.generateComponent(testComponent)
31
+ const htmlFile = result.files.find((file) => file.fileType === FileType.HTML)
32
+
33
+ expect(htmlFile).toBeDefined()
34
+ expect(htmlFile?.content).toContain('data-node-id="my-custom-id"')
35
+ })
36
+
37
+ test('adds data-node-id to component instance wrapper tags when explicitly set', async () => {
38
+ const generator = createHTMLComponentGenerator()
39
+ const childComponent = component('ChildComponent', elementNode('container', {}))
40
+ generator.addExternalComponents({
41
+ externals: {
42
+ ChildComponent: childComponent,
43
+ },
44
+ options: {},
45
+ })
46
+
47
+ const parentComponent = component(
48
+ 'ParentComponent',
49
+ elementNode(
50
+ 'container',
51
+ {},
52
+ [
53
+ elementNode(
54
+ 'ChildComponent',
55
+ { 'data-node-id': { type: 'static', content: 'component-wrapper-id' } },
56
+ [],
57
+ {
58
+ type: 'local',
59
+ }
60
+ ),
61
+ ]
62
+ )
63
+ )
64
+ const result = await generator.generateComponent(parentComponent)
65
+ const htmlFile = result.files.find((file) => file.fileType === FileType.HTML)
66
+
67
+ expect(htmlFile).toBeDefined()
68
+ expect(htmlFile?.content).toContain('data-node-id="component-wrapper-id"')
69
+ })
70
+
71
+ test('adds data-node-id to code embed wrapper when explicitly set', async () => {
72
+ const generator = createHTMLComponentGenerator()
73
+ const testComponent = component(
74
+ 'TestComponent',
75
+ elementNode('container', {}, [
76
+ elementNode('html-node', {
77
+ 'data-node-id': { type: 'static', content: 'embed-wrapper-id' },
78
+ html: { type: 'raw', content: '<div>Embedded HTML</div>' },
79
+ }),
80
+ ])
81
+ )
82
+ const result = await generator.generateComponent(testComponent)
83
+ const htmlFile = result.files.find((file) => file.fileType === FileType.HTML)
84
+
85
+ expect(htmlFile).toBeDefined()
86
+ expect(htmlFile?.content).toContain('data-node-id="embed-wrapper-id"')
87
+ })
88
+
89
+ test('does not add data-node-id when not explicitly set', async () => {
90
+ const generator = createHTMLComponentGenerator()
91
+ const testComponent = component('TestComponent', elementNode('container', {}))
92
+ const result = await generator.generateComponent(testComponent)
93
+ const htmlFile = result.files.find((file) => file.fileType === FileType.HTML)
94
+
95
+ expect(htmlFile).toBeDefined()
96
+ expect(htmlFile?.content).not.toContain('data-node-id')
97
+ })
98
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teleporthq/teleport-component-generator-html",
3
- "version": "0.42.0",
3
+ "version": "0.42.10",
4
4
  "description": "Component generator customization, capable of creating plain html",
5
5
  "author": "teleportHQ",
6
6
  "license": "MIT",
@@ -24,13 +24,13 @@
24
24
  "build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
25
25
  },
26
26
  "dependencies": {
27
- "@teleporthq/teleport-component-generator": "^0.42.0",
27
+ "@teleporthq/teleport-component-generator": "^0.42.10",
28
28
  "@teleporthq/teleport-plugin-css": "^0.42.0",
29
- "@teleporthq/teleport-plugin-html-base-component": "^0.42.0",
29
+ "@teleporthq/teleport-plugin-html-base-component": "^0.42.10",
30
30
  "@teleporthq/teleport-plugin-import-statements-html": "^0.42.0",
31
31
  "@teleporthq/teleport-postprocessor-prettier-html": "^0.42.0",
32
32
  "@teleporthq/teleport-shared": "^0.42.0",
33
33
  "@teleporthq/teleport-types": "^0.42.0"
34
34
  },
35
- "gitHead": "5460b740bf90a0a320f7a6b56119e3aa03fc3609"
35
+ "gitHead": "f5300682d2480a48043e0301458355743aa3e629"
36
36
  }