Skip to content

Commit

Permalink
fix: respond to PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Aug 23, 2021
1 parent fb0da7a commit ebb4f49
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/@lwc/engine-core/src/framework/stylesheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export function getStylesheetsContent(vm: VM, template: Template): string[] {
return content;
}

// It might be worth caching this to avoid doing the lookup repeatedly, but
// perf testing has not shown it to be a huge improvement yet:
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
function getNearestNativeShadowComponent(vm: VM): VM | null {
let owner: VM | null = vm;
while (!isNull(owner)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import path from 'path';
import fs from 'fs';
import os from 'os';
import mkdirp from 'mkdirp';

const NUM_COMPONENTS = 1000;

Expand All @@ -33,7 +32,7 @@ export function generateStyledComponents() {
const css = `div { color: ${i.toString(16).padStart(6, '0')}}`;
const html = '<template><div></div></template>';

mkdirp.sync(path.dirname(jsFilename));
fs.mkdirSync(path.dirname(jsFilename), { recursive: true });
fs.writeFileSync(jsFilename, js, 'utf-8');
fs.writeFileSync(cssFilename, css, 'utf-8');
fs.writeFileSync(htmlFilename, html, 'utf-8');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ export function styledComponentBenchmark(name, componentOrComponents) {

const isArray = Array.isArray(componentOrComponents);

run(() => {
run(async () => {
for (let i = 0; i < 1000; i++) {
const elm = createElement(isArray ? `styled-component${i}` : 'styled-component', {
is: isArray ? componentOrComponents[i] : componentOrComponents,
});
document.body.appendChild(elm);
elms.push(elm);
}
return Promise.resolve();
});

after(() => {
Expand Down

0 comments on commit ebb4f49

Please sign in to comment.