Skip to content

Commit

Permalink
refactor(core): remove overrideDocument and use `element.ownerDocum…
Browse files Browse the repository at this point in the history
…ent`
  • Loading branch information
mhevery committed Jul 8, 2021
1 parent 76579e9 commit aee73a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/core/render/jsx/mark_dirty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function scheduleRender(doc: QDocument): Promise<HostElements> {
const qrl = host.getAttribute(AttributeMarker.ComponentTemplate)! as any as QRL;
qDev && assertString(qrl);
const props: Props = extractPropsFromElement(host);
jsxRenderComponent(host, qrl, waitOn, props, doc);
jsxRenderComponent(host, qrl, waitOn, props);
hosts.push(host);
});

Expand Down
15 changes: 4 additions & 11 deletions src/core/render/jsx/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,7 @@ function visitJSXDomNode(
inputPropChangesDetected;
if (componentUrl && inputPropChangesDetected) {
// TODO: better way of converting string to QRL.
jsxRenderComponent(
reconcileElement,
componentUrl as any as QRL,
waitOn,
jsxNode.props,
document
);
jsxRenderComponent(reconcileElement, componentUrl as any as QRL, waitOn, jsxNode.props);
}
if (!componentUrl && !('innerHTML' in jsxNode.props || 'innerText' in jsxNode.props)) {
// we don't process children if we have a component, as component is responsible for projection.
Expand All @@ -148,8 +142,7 @@ export function jsxRenderComponent(
hostElement: Element,
componentUrl: QRL,
waitOn: AsyncHostElementPromises,
props: Props,
overrideDocument: Document = document
props: Props
) {
// we need to render child component only if the inputs to the component changed.
const componentOrPromise = qImport<JSXFactory>(hostElement, componentUrl);
Expand All @@ -158,7 +151,7 @@ export function jsxRenderComponent(
componentOrPromise.then((component) => {
const waitOn = [hostElement];
visitJSXComponentNode(
overrideDocument,
hostElement.ownerDocument,
waitOn,
hostElement,
hostElement.firstChild,
Expand All @@ -170,7 +163,7 @@ export function jsxRenderComponent(
);
} else {
visitJSXComponentNode(
overrideDocument,
hostElement.ownerDocument,
waitOn,
hostElement,
hostElement.firstChild,
Expand Down

0 comments on commit aee73a9

Please sign in to comment.