@knowark/componarkjs 1.10.0 → 1.10.1
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.
|
@@ -18,8 +18,6 @@ export class Component extends globalThis.HTMLElement {
|
|
|
18
18
|
define(tag, element, styles)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
static format = Symbol.for('format')
|
|
22
|
-
|
|
23
21
|
/**
|
|
24
22
|
* @param {object} styleMap
|
|
25
23
|
* @return {string} **/
|
|
@@ -45,11 +43,7 @@ export class Component extends globalThis.HTMLElement {
|
|
|
45
43
|
|
|
46
44
|
/** @param {string} content */
|
|
47
45
|
set content (content) {
|
|
48
|
-
|
|
49
|
-
let template = document.createElement('template')
|
|
50
|
-
template.innerHTML = content
|
|
51
|
-
template = format ? format(template) : template
|
|
52
|
-
this.replaceChildren(template.content)
|
|
46
|
+
this.innerHTML = content
|
|
53
47
|
}
|
|
54
48
|
|
|
55
49
|
/** @return {string} */
|
|
@@ -496,25 +496,4 @@ describe('Component', () => {
|
|
|
496
496
|
|
|
497
497
|
expect(result).toEqual('background-primary shadow-small')
|
|
498
498
|
})
|
|
499
|
-
|
|
500
|
-
it('allows to use a globally provided template formatter', () => {
|
|
501
|
-
let formattedCalled = false
|
|
502
|
-
globalThis[Component.format] = (template) => {
|
|
503
|
-
formattedCalled = true
|
|
504
|
-
const paragraph = document.createElement('p')
|
|
505
|
-
paragraph.textContent = 'FORMATTED_CONTENT'
|
|
506
|
-
template.content.replaceChildren(paragraph)
|
|
507
|
-
return template
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
container.innerHTML = `
|
|
511
|
-
<mock-content-component class></mock-content-component>
|
|
512
|
-
`
|
|
513
|
-
|
|
514
|
-
const element = container.querySelector('mock-content-component p')
|
|
515
|
-
|
|
516
|
-
expect(formattedCalled).toBe(true)
|
|
517
|
-
expect(element.textContent).toEqual('FORMATTED_CONTENT')
|
|
518
|
-
delete globalThis[Component.format]
|
|
519
|
-
})
|
|
520
499
|
})
|