Skip to content

Commit bd80057

Browse files
authored
test(engine-server): Improve test coverage (salesforce#1950)
1 parent 5599a1c commit bd80057

File tree

9 files changed

+62
-9
lines changed

9 files changed

+62
-9
lines changed

packages/@lwc/engine-core/src/framework/renderer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export interface Renderer<N = HostNode, E = HostElement> {
4444
getElementsByTagName(element: E, tagNameOrWildCard: string): HTMLCollection;
4545
getElementsByClassName(element: E, names: string): HTMLCollection;
4646
isConnected(node: N): boolean;
47-
tagName(element: E): string;
4847
insertGlobalStylesheet(content: string): void;
4948
assertInstanceOfHTMLElement?(elm: any, msg: string): void;
5049
}

packages/@lwc/engine-dom/src/renderer.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ export const renderer: Renderer<Node, Element> = {
146146
return node.isConnected;
147147
},
148148

149-
tagName(element: Element): string {
150-
return element.tagName;
151-
},
152-
153149
insertGlobalStylesheet(content: string): void {
154150
if (!isUndefined(globalStylesheets[content])) {
155151
return;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<x-attribute-style>
2+
<template shadow-root>
3+
<div style="color: red;"></div>
4+
<div style="color: blue; background: black; border: 1px solid red;"></div>
5+
<div
6+
style="border-width: 1px; border-style: solid; border-color: red;"
7+
></div>
8+
<div style="color: salmon; background-color: chocolate;"></div>
9+
<x-child style="color: red;"><template shadow-root></template></x-child>
10+
<x-child style="color: blue; background: black; border: 1px solid red;">
11+
<template shadow-root></template>
12+
</x-child>
13+
<x-child style="border-width: 1px; border-style: solid; border-color: red;">
14+
<template shadow-root></template>
15+
</x-child>
16+
<x-child style="color: salmon; background-color: chocolate;">
17+
<template shadow-root></template>
18+
</x-child>
19+
</template>
20+
</x-attribute-style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<template>
2+
<!-- Standard element, simple value -->
3+
<div style="color: red;"></div>
4+
5+
<!-- Standard element, multiple values -->
6+
<div style="color: blue; background: black; border: 1px solid red;"></div>
7+
8+
<!-- Standard element, complex values -->
9+
<div style="border-width: 1px; border-style: solid; border-color: red;"></div>
10+
11+
<!-- Standard element, dynamic value -->
12+
<div style={dynamicStyle}></div>
13+
14+
<!-- Component, simple value -->
15+
<x-child style="color: red;"></x-child>
16+
17+
<!-- Component, multiple values -->
18+
<x-child style="color: blue; background: black; border: 1px solid red;"></x-child>
19+
20+
<!-- Component, complex values -->
21+
<x-child style="border-width: 1px; border-style: solid; border-color: red;"></x-child>
22+
23+
<!-- Component, dynamic value -->
24+
<x-child style={dynamicStyle}></x-child>
25+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { LightningElement } from 'lwc';
2+
3+
export default class StyleAttribute extends LightningElement {
4+
dynamicStyle = 'color: salmon; background-color: chocolate;'
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { LightningElement } from 'lwc';
2+
3+
export default class Child extends LightningElement {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<x-methods-noop><template shadow-root></template></x-methods-noop>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { LightningElement } from 'lwc';
2+
3+
export default class MethodsNoop extends LightningElement {
4+
connectedCallback() {
5+
expect(() => this.addEventListener('click', () => {})).not.toThrow();
6+
expect(() => this.removeEventListener('click', () => {})).not.toThrow();
7+
}
8+
}

packages/@lwc/engine-server/src/renderer.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,6 @@ export const renderer: Renderer<HostNode, HostElement> = {
293293
return true;
294294
},
295295

296-
tagName(element) {
297-
return element.name;
298-
},
299-
300296
insertGlobalStylesheet() {
301297
// Noop on SSR (for now). This need to be reevaluated whenever we will implement support for
302298
// synthetic shadow.

0 commit comments

Comments
 (0)