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(engine): close #849 by implementing move hook #852

Merged
merged 1 commit into from
Nov 22, 2018

Conversation

caridy
Copy link
Contributor

@caridy caridy commented Nov 21, 2018

Details

We were using the insert hook for the cases when we just move an existing node up or down in the children collection. This was causing the node to be re-patched, which can produces unpredictable results.

Does this PR introduce a breaking change?

  • No

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 058e40c | Target commit: fc9a396

lwc-engine-benchmark

table-append-1k metric base(058e40c) target(fc9a396) trend
benchmark-table/append/1k duration 147.05 (±3.15 ms) 149.55 (±3.85 ms) +2.5ms (1.7%) 👌
table-clear-1k metric base(058e40c) target(fc9a396) trend
benchmark-table/clear/1k duration 5.90 (±0.20 ms) 6.20 (±0.50 ms) +0.3ms (5.1%) 👎
table-create-10k metric base(058e40c) target(fc9a396) trend
benchmark-table/create/10k duration 883.15 (±7.05 ms) 874.35 (±9.10 ms) -8.8ms (1.0%) 👍
table-create-1k metric base(058e40c) target(fc9a396) trend
benchmark-table/create/1k duration 117.30 (±2.15 ms) 117.45 (±3.25 ms) +0.1ms (0.1%) 👌
table-update-10th-1k metric base(058e40c) target(fc9a396) trend
benchmark-table/update-10th/1k duration 76.95 (±2.45 ms) 87.70 (±2.20 ms) +10.8ms (14.0%) 👎
tablecmp-append-1k metric base(058e40c) target(fc9a396) trend
benchmark-table-component/append/1k duration 253.00 (±6.40 ms) 252.65 (±6.80 ms) -0.4ms (0.1%) 👌
tablecmp-clear-1k metric base(058e40c) target(fc9a396) trend
benchmark-table-component/clear/1k duration 11.60 (±1.70 ms) 12.90 (±2.00 ms) +1.3ms (11.2%) 👎
tablecmp-create-10k metric base(058e40c) target(fc9a396) trend
benchmark-table-component/create/10k duration 1743.30 (±11.50 ms) 1726.25 (±10.45 ms) -17.1ms (1.0%) 👍
tablecmp-create-1k metric base(058e40c) target(fc9a396) trend
benchmark-table-component/create/1k duration 210.85 (±5.25 ms) 209.40 (±5.60 ms) -1.5ms (0.7%) 👌
tablecmp-update-10th-1k metric base(058e40c) target(fc9a396) trend
benchmark-table-component/update-10th/1k duration 69.90 (±4.40 ms) 71.45 (±4.70 ms) +1.5ms (2.2%) 👌
wc-append-1k metric base(058e40c) target(fc9a396) trend
benchmark-table-wc/append/1k duration 255.75 (±7.10 ms) 255.30 (±6.15 ms) -0.4ms (0.2%) 👌
wc-clear-1k metric base(058e40c) target(fc9a396) trend
benchmark-table-wc/clear/1k duration 21.05 (±2.70 ms) 22.25 (±2.40 ms) +1.2ms (5.7%) 👌
wc-create-10k metric base(058e40c) target(fc9a396) trend
benchmark-table-wc/create/10k duration 1823.90 (±34.60 ms) 1814.80 (±36.55 ms) -9.1ms (0.5%) 👌
wc-create-1k metric base(058e40c) target(fc9a396) trend
benchmark-table-wc/create/1k duration 220.65 (±3.10 ms) 221.60 (±3.85 ms) +0.9ms (0.4%) 👌
wc-update-10th-1k metric base(058e40c) target(fc9a396) trend
benchmark-table-wc/update-10th/1k duration 69.65 (±4.85 ms) 71.95 (±4.85 ms) +2.3ms (3.3%) 👌

@@ -117,8 +117,7 @@ export class SyntheticShadowRoot extends DocumentFragment implements ShadowRoot
return getHost(this).baseURI;
}
get isConnected(this: SyntheticShadowRootInterface) {
// @ts-ignore remove this after upgrading ts 3.x
return getHost(this).isConnected;
return (compareDocumentPosition.call(document, getHost(this)) & DOCUMENT_POSITION_CONTAINED_BY) !== 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this changing? Is this relevant to the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, probably something that should have done in another PR, but there are failures on the accessibility lib that we have implemented for lightning namespace that is failing because this.template.isConnected is always undefined or false, that's because it is not implemented everywhere and we are not polyfilling it. This is the proper implementation that works across the board for shadows

expect(elm.shadowRoot.textContent).toBe('5431');
elm.sort('ASC');
return Promise.resolve().then(() => {
expect(elm.shadowRoot.textContent).toBe('1345');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we see before this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was throwing during the first rehydration because it was trying to repatch the element while moving it from one position to another.

@@ -34,7 +34,7 @@ export interface WireHash {
export interface RegisterDecoratorMeta {
readonly publicMethods?: string[];
readonly publicProps?: PropsDef;
readonly track?: string[];
readonly track?: TrackDef;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a mistake, diego was passing the right value from compiler, but we were typing that incorrectly.

Copy link
Member

@ekashida ekashida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@diervo
Copy link
Contributor

diervo commented Nov 22, 2018

@davidturissini you should re-review this once you are back (and the retargeting as well), but need to merge it to unblock LGC.

@diervo diervo merged commit 6c05d12 into master Nov 22, 2018
@diervo diervo deleted the caridy/issue-849/diffing-move branch November 22, 2018 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants