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): shadow root childNodes #374

Merged
merged 9 commits into from
Jun 6, 2018

Conversation

davidturissini
Copy link
Contributor

Details

Adding childNodes shim to shadow root and templated elements.

Does this PR introduce a breaking change?

  • Yes
  • No

childNodes: { value : [] },
childNodes: {
get(this: ShadowRoot): Element[] {
if (process.env.NODE_ENV !== 'production') {
Copy link
Contributor

Choose a reason for hiding this comment

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

this warning is tricky because it only appears when in fallback mode. On the other hands, blacklist will always throw. Maybe we need a grayList that wraps the original functionality with a warning, but still allow you to use it.

if (process.env.NODE_ENV !== 'production') {
assert.logWarning(`childNodes on ${this} returns a live nodelist which is not stable. Use querySelectorAll instead.`);
}
return EmptyArray;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is supposed to return empty array only when the element tagName is a slot, otherwise it should return the proper values but as a static list, not a live one. I think that's better for selenium/webdriver, while keeping users out of trouble.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 1e0bc28 | Target commit: d001489

lwc-engine-benchmark

table-append-1k metric base(1e0bc28) target(d001489) trend
benchmark-table/append/1k duration 142.30 (± 3.00 ms) 147.00 (± 5.00 ms) -3.30% 👎
table-clear-1k metric base(1e0bc28) target(d001489) trend
benchmark-table/clear/1k duration 11.20 (± 0.40 ms) 11.40 (± 0.40 ms) -1.79% 👌
table-create-10k metric base(1e0bc28) target(d001489) trend
benchmark-table/create/10k duration 839.30 (± 6.80 ms) 839.60 (± 6.10 ms) -0.04% 👌
table-create-1k metric base(1e0bc28) target(d001489) trend
benchmark-table/create/1k duration 102.80 (± 1.90 ms) 101.60 (± 2.40 ms) 1.17% 👍
table-update-10th-1k metric base(1e0bc28) target(d001489) trend
benchmark-table/update-10th/1k duration 92.10 (± 5.25 ms) 90.90 (± 5.20 ms) 1.30% 👌
tablecmp-append-1k metric base(1e0bc28) target(d001489) trend
benchmark-table-component/append/1k duration 252.80 (± 3.30 ms) 250.80 (± 3.10 ms) 0.79% 👌
tablecmp-clear-1k metric base(1e0bc28) target(d001489) trend
benchmark-table/clear/1k duration 34.90 (± 1.70 ms) 34.35 (± 1.95 ms) 1.58% 👌
tablecmp-create-10k metric base(1e0bc28) target(d001489) trend
benchmark-table-component/create/10k duration 1701.90 (± 9.70 ms) 1690.20 (± 7.40 ms) 0.69% 👍
tablecmp-create-1k metric base(1e0bc28) target(d001489) trend
benchmark-table-component/create/1k duration 196.80 (± 3.90 ms) 193.70 (± 4.00 ms) 1.58% 👍
tablecmp-update-10th-1k metric base(1e0bc28) target(d001489) trend
benchmark-table-component/update-10th/1k duration 74.10 (± 5.30 ms) 72.40 (± 3.90 ms) 2.29% 👌

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 1e0bc28 | Target commit: dd0dc8b

lwc-engine-benchmark

table-append-1k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table/append/1k duration 142.30 (± 3.00 ms) 143.40 (± 3.00 ms) -0.77% 👌
table-clear-1k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table/clear/1k duration 11.20 (± 0.40 ms) 11.35 (± 0.35 ms) -1.34% 👌
table-create-10k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table/create/10k duration 839.30 (± 6.80 ms) 840.50 (± 5.50 ms) -0.14% 👌
table-create-1k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table/create/1k duration 102.80 (± 1.90 ms) 100.10 (± 1.60 ms) 2.63% 👍
table-update-10th-1k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table/update-10th/1k duration 92.10 (± 5.25 ms) 84.30 (± 4.90 ms) 8.47% 👍
tablecmp-append-1k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table-component/append/1k duration 252.80 (± 3.30 ms) 252.90 (± 5.30 ms) -0.04% 👌
tablecmp-clear-1k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table/clear/1k duration 34.90 (± 1.70 ms) 35.65 (± 1.75 ms) -2.15% 👌
tablecmp-create-10k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table-component/create/10k duration 1701.90 (± 9.70 ms) 1680.40 (± 8.90 ms) 1.26% 👍
tablecmp-create-1k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table-component/create/1k duration 196.80 (± 3.90 ms) 196.50 (± 3.80 ms) 0.15% 👌
tablecmp-update-10th-1k metric base(1e0bc28) target(dd0dc8b) trend
benchmark-table-component/update-10th/1k duration 74.10 (± 5.30 ms) 75.00 (± 3.60 ms) -1.21% 👌

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 1e0bc28 | Target commit: 6e8795a

lwc-engine-benchmark

table-append-1k metric base(1e0bc28) target(6e8795a) trend
benchmark-table/append/1k duration 142.30 (± 3.00 ms) 145.20 (± 4.60 ms) -2.04% 👎
table-clear-1k metric base(1e0bc28) target(6e8795a) trend
benchmark-table/clear/1k duration 11.20 (± 0.40 ms) 11.40 (± 0.50 ms) -1.79% 👌
table-create-10k metric base(1e0bc28) target(6e8795a) trend
benchmark-table/create/10k duration 839.30 (± 6.80 ms) 857.80 (± 5.00 ms) -2.20% 👎
table-create-1k metric base(1e0bc28) target(6e8795a) trend
benchmark-table/create/1k duration 102.80 (± 1.90 ms) 103.30 (± 1.70 ms) -0.49% 👌
table-update-10th-1k metric base(1e0bc28) target(6e8795a) trend
benchmark-table/update-10th/1k duration 92.10 (± 5.25 ms) 89.20 (± 5.30 ms) 3.15% 👌
tablecmp-append-1k metric base(1e0bc28) target(6e8795a) trend
benchmark-table-component/append/1k duration 252.80 (± 3.30 ms) 257.10 (± 4.40 ms) -1.70% 👎
tablecmp-clear-1k metric base(1e0bc28) target(6e8795a) trend
benchmark-table/clear/1k duration 34.90 (± 1.70 ms) 35.60 (± 1.70 ms) -2.01% 👌
tablecmp-create-10k metric base(1e0bc28) target(6e8795a) trend
benchmark-table-component/create/10k duration 1701.90 (± 9.70 ms) 1700.10 (± 6.50 ms) 0.11% 👌
tablecmp-create-1k metric base(1e0bc28) target(6e8795a) trend
benchmark-table-component/create/1k duration 196.80 (± 3.90 ms) 196.70 (± 3.20 ms) 0.05% 👌
tablecmp-update-10th-1k metric base(1e0bc28) target(6e8795a) trend
benchmark-table-component/update-10th/1k duration 74.10 (± 5.30 ms) 77.40 (± 4.00 ms) -4.45% 👎

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 1e0bc28 | Target commit: 8d9dd0a

lwc-engine-benchmark

table-append-1k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table/append/1k duration 142.30 (± 3.00 ms) 145.00 (± 5.80 ms) -1.90% 👌
table-clear-1k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table/clear/1k duration 11.20 (± 0.40 ms) 11.15 (± 0.45 ms) 0.45% 👌
table-create-10k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table/create/10k duration 839.30 (± 6.80 ms) 843.70 (± 5.10 ms) -0.52% 👎
table-create-1k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table/create/1k duration 102.80 (± 1.90 ms) 101.50 (± 1.90 ms) 1.26% 👍
table-update-10th-1k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table/update-10th/1k duration 92.10 (± 5.25 ms) 85.10 (± 4.80 ms) 7.60% 👍
tablecmp-append-1k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table-component/append/1k duration 252.80 (± 3.30 ms) 258.30 (± 5.40 ms) -2.18% 👎
tablecmp-clear-1k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table/clear/1k duration 34.90 (± 1.70 ms) 35.75 (± 1.85 ms) -2.44% 👌
tablecmp-create-10k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table-component/create/10k duration 1701.90 (± 9.70 ms) 1688.60 (± 8.00 ms) 0.78% 👍
tablecmp-create-1k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table-component/create/1k duration 196.80 (± 3.90 ms) 200.40 (± 3.60 ms) -1.83% 👎
tablecmp-update-10th-1k metric base(1e0bc28) target(8d9dd0a) trend
benchmark-table-component/update-10th/1k duration 74.10 (± 5.30 ms) 72.80 (± 3.50 ms) 1.75% 👌

if (process.env.NODE_ENV !== 'production') {
assert.logWarning(`childNodes on ${this} returns a live nodelist which is not stable. Use querySelectorAll instead.`);
}
const vm = getElementOwnerVM(this) as VM;
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to ownerVM

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 1e0bc28 | Target commit: 01d938c

lwc-engine-benchmark

table-append-1k metric base(1e0bc28) target(01d938c) trend
benchmark-table/append/1k duration 142.30 (± 3.00 ms) 148.60 (± 5.90 ms) -4.43% 👎
table-clear-1k metric base(1e0bc28) target(01d938c) trend
benchmark-table/clear/1k duration 11.20 (± 0.40 ms) 11.70 (± 0.40 ms) -4.46% 👎
table-create-10k metric base(1e0bc28) target(01d938c) trend
benchmark-table/create/10k duration 839.30 (± 6.80 ms) 841.10 (± 6.20 ms) -0.21% 👌
table-create-1k metric base(1e0bc28) target(01d938c) trend
benchmark-table/create/1k duration 102.80 (± 1.90 ms) 101.50 (± 2.00 ms) 1.26% 👍
table-update-10th-1k metric base(1e0bc28) target(01d938c) trend
benchmark-table/update-10th/1k duration 92.10 (± 5.25 ms) 86.00 (± 4.70 ms) 6.62% 👌
tablecmp-append-1k metric base(1e0bc28) target(01d938c) trend
benchmark-table-component/append/1k duration 252.80 (± 3.30 ms) 259.70 (± 3.90 ms) -2.73% 👎
tablecmp-clear-1k metric base(1e0bc28) target(01d938c) trend
benchmark-table/clear/1k duration 34.90 (± 1.70 ms) 35.90 (± 1.10 ms) -2.87% 👌
tablecmp-create-10k metric base(1e0bc28) target(01d938c) trend
benchmark-table-component/create/10k duration 1701.90 (± 9.70 ms) 1692.30 (± 9.70 ms) 0.56% 👍
tablecmp-create-1k metric base(1e0bc28) target(01d938c) trend
benchmark-table-component/create/1k duration 196.80 (± 3.90 ms) 200.20 (± 2.70 ms) -1.73% 👎
tablecmp-update-10th-1k metric base(1e0bc28) target(01d938c) trend
benchmark-table-component/update-10th/1k duration 74.10 (± 5.30 ms) 75.10 (± 4.55 ms) -1.35% 👌

const elm = createElement('x-child-node-parent', { is: Parent });
document.body.appendChild(elm);
const slot = elm.shadowRoot.querySelector('x-child-node-with-slot').shadowRoot.querySelector('slot');
expect(slot.childNodes.length).toBe(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

expect(slot.childNodes).toHaveLength(0); will give a better failure message.

Same comment for cases below.

browser.waitUntil(() => {
return element.getText() === 'Title:task 1 Completed:false';
}, 500, 'expect text to be different after 0.5s');
browser.pause(50);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the browser.execute call inside the waitUntil instead of this pause?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! I didn't realize you could do that.

browser.waitUntil(() => {
return element.getText() === 'Title:task 1 Completed:false';
}, 500, 'expect text to be different after 0.5s');
browser.pause(50);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above - can we add browser.execute to the wait?

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 485357e | Target commit: 476b8e9

lwc-engine-benchmark

table-append-1k metric base(485357e) target(476b8e9) trend
benchmark-table/append/1k duration 145.70 (± 5.80 ms) 143.90 (± 4.70 ms) 1.24% 👌
table-clear-1k metric base(485357e) target(476b8e9) trend
benchmark-table/clear/1k duration 11.00 (± 0.50 ms) 11.30 (± 0.60 ms) -2.73% 👎
table-create-10k metric base(485357e) target(476b8e9) trend
benchmark-table/create/10k duration 849.80 (± 4.40 ms) 837.25 (± 10.30 ms) 1.48% 👍
table-create-1k metric base(485357e) target(476b8e9) trend
benchmark-table/create/1k duration 101.80 (± 2.30 ms) 100.60 (± 2.10 ms) 1.18% 👌
table-update-10th-1k metric base(485357e) target(476b8e9) trend
benchmark-table/update-10th/1k duration 89.80 (± 5.50 ms) 92.30 (± 5.15 ms) -2.78% 👌
tablecmp-append-1k metric base(485357e) target(476b8e9) trend
benchmark-table-component/append/1k duration 252.20 (± 5.70 ms) 255.70 (± 3.40 ms) -1.39% 👌
tablecmp-clear-1k metric base(485357e) target(476b8e9) trend
benchmark-table/clear/1k duration 34.90 (± 1.10 ms) 36.45 (± 1.45 ms) -4.44% 👎
tablecmp-create-10k metric base(485357e) target(476b8e9) trend
benchmark-table-component/create/10k duration 1690.20 (± 13.00 ms) 1700.60 (± 10.80 ms) -0.62% 👌
tablecmp-create-1k metric base(485357e) target(476b8e9) trend
benchmark-table-component/create/1k duration 196.30 (± 3.70 ms) 196.10 (± 2.80 ms) 0.10% 👌
tablecmp-update-10th-1k metric base(485357e) target(476b8e9) trend
benchmark-table-component/update-10th/1k duration 74.60 (± 3.80 ms) 72.30 (± 4.30 ms) 3.08% 👌

Copy link
Contributor

@caridy caridy left a comment

Choose a reason for hiding this comment

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

there is a coming PR right after.

@davidturissini davidturissini merged commit a4c21a0 into master Jun 6, 2018
@davidturissini davidturissini deleted the dturissini/shadow-root-children branch June 6, 2018 20:07
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.

3 participants