Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(platform-server): align server renderer interface with base renderer #47868

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 13 additions & 15 deletions packages/platform-server/src/server_renderer.ts
Expand Up @@ -69,7 +69,7 @@ class DefaultServerRenderer2 implements Renderer2 {

destroyNode = null;

createElement(name: string, namespace?: string, debugInfo?: any): any {
createElement(name: string, namespace?: string): any {
if (namespace) {
const doc = this.document || getDOM().getDefaultDocument();
return doc.createElementNS(NAMESPACE_URIS[namespace], name);
Expand All @@ -78,11 +78,11 @@ class DefaultServerRenderer2 implements Renderer2 {
return getDOM().createElement(name, this.document);
}

createComment(value: string, debugInfo?: any): any {
createComment(value: string): any {
return getDOM().getDefaultDocument().createComment(value);
}

createText(value: string, debugInfo?: any): any {
createText(value: string): any {
const doc = getDOM().getDefaultDocument();
return doc.createTextNode(value);
}
Expand All @@ -105,18 +105,16 @@ class DefaultServerRenderer2 implements Renderer2 {
}
}

selectRootElement(selectorOrNode: string|any, debugInfo?: any): any {
let el: any;
if (typeof selectorOrNode === 'string') {
el = this.document.querySelector(selectorOrNode);
if (!el) {
throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
}
} else {
el = selectorOrNode;
selectRootElement(selectorOrNode: string|any, preserveContent?: boolean): any {
const el = typeof selectorOrNode === 'string' ? this.document.querySelector(selectorOrNode) :
selectorOrNode;
if (!el) {
throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
}
while (el.firstChild) {
el.removeChild(el.firstChild);
if (!preserveContent) {
while (el.firstChild) {
el.removeChild(el.firstChild);
}
}
return el;
}
Expand Down Expand Up @@ -271,7 +269,7 @@ class EmulatedEncapsulationServerRenderer2 extends DefaultServerRenderer2 {
}

override createElement(parent: any, name: string): Element {
const el = super.createElement(parent, name, this.document);
const el = super.createElement(parent, name);
super.setAttribute(el, this.contentAttr, '');
return el;
}
Expand Down