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: unify the descriptor creation process for restrictions #1144

Merged
merged 6 commits into from
Mar 29, 2019
Merged

fix: unify the descriptor creation process for restrictions #1144

merged 6 commits into from
Mar 29, 2019

Conversation

ravijayaramappa
Copy link
Contributor

Details

Fixes #1124

Does this PR introduce a breaking change?

  • Yes
  • No

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@@ -37,7 +38,16 @@ import {
removeAttribute,
removeAttributeNS,
} from '../env/element';
import { create } from './../shared/language';

function generateDescriptor(options: undefined | object): object {
Copy link
Member

Choose a reason for hiding this comment

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

Let's make this method signature a little more contained:

Suggested change
function generateDescriptor(options: undefined | object): object {
function generateDescriptor(options: PropertyDescriptor): object {

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@@ -393,37 +383,31 @@ function getCustomElementRestrictionsDescriptors(
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML')!;
const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent')!;
return assign(descriptors, {
innerHTML: {
innerHTML: generateDescriptor({
Copy link
Contributor

Choose a reason for hiding this comment

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

this one is not correct because it should be enumerable I think...

I think you need two methods, not just one... one for methods (which they are always nonenumerable, non writable), and one for regular accessors which are normally enumerables, and non-writables.

Copy link
Contributor Author

@ravijayaramappa ravijayaramappa Mar 29, 2019

Choose a reason for hiding this comment

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

@caridy like we spoke, I updated the descriptors to match the native config. Here's the native descriptor shape for reference

Node.prototype.appendChild {value: ƒ, writable: true, enumerable: true, configurable: true}
Node.prototype.insertBefore {value: ƒ, writable: true, enumerable: true, configurable: true}
Node.prototype.removeChild {value: ƒ, writable: true, enumerable: true, configurable: true}
Node.prototype.replaceChild {value: ƒ, writable: true, enumerable: true, configurable: true}
Node.prototype.nodeValue {get: ƒ, set: ƒ, enumerable: true, configurable: true}
Node.prototype.textContent {get: ƒ, set: ƒ, enumerable: true, configurable: true}

Element.prototype.innerHTML {get: ƒ, set: ƒ, enumerable: true, configurable: true}
Element.prototype.outerHTML {get: ƒ, set: ƒ, enumerable: true, configurable: true}
Element.prototype.getAttribute {value: ƒ, writable: true, enumerable: true, configurable: true}
Element.prototype.setAttribute {value: ƒ, writable: true, enumerable: true, configurable: true}
Element.prototype.setAttributeNS {value: ƒ, writable: true, enumerable: true, configurable: true}
Element.prototype.removeAttribute {value: ƒ, writable: true, enumerable: true, configurable: true} 
Element.prototype.removeAttributeNS {value: ƒ, writable: true, enumerable: true, configurable: true}
Element.prototype.tagName {get: ƒ, set: ƒ, enumerable: true, configurable: true}

ShadowRoot.prototype.innerHTML {get: ƒ, set: ƒ, enumerable: true, configurable: true}

EventTarget.prototype.addEventListener {value: ƒ, writable: true, enumerable: true, configurable: true}

DocumentFragment.prototype.querySelector {value: ƒ, writable: true, enumerable: true, configurable: true}
DocumentFragment.prototype.querySelectorAll {value: ƒ, writable: true, enumerable: true, configurable: true}

Document.prototype.getSelection {value: ƒ, writable: true, enumerable: true, configurable: true} 
Document.prototype.elementsFromPoint {value: ƒ, writable: true, enumerable: true, configurable: true}```

@salesforce-best-lwc-internal

This comment has been minimized.

@@ -37,7 +38,27 @@ import {
removeAttribute,
removeAttributeNS,
} from '../env/element';
import { create } from './../shared/language';

function generateDataDescriptor(options: PropertyDescriptor): object {
Copy link
Member

Choose a reason for hiding this comment

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

Another nitpick you can also constraint the output of the function.

Suggested change
function generateDataDescriptor(options: PropertyDescriptor): object {
function generateDataDescriptor(options: PropertyDescriptor): PropertyDescriptor {

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: fee643c | Target commit: 6bdcfba

lwc-engine-benchmark

table-append-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table/append/1k duration 159.70 (±5.75 ms) 156.15 (±4.85 ms) -3.5ms (2.2%) 👌
table-clear-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table/clear/1k duration 10.85 (±0.75 ms) 10.75 (±0.45 ms) -0.1ms (0.9%) 👌
table-create-10k metric base(fee643c) target(6bdcfba) trend
benchmark-table/create/10k duration 887.65 (±7.75 ms) 906.45 (±5.15 ms) +18.8ms (2.1%) 👎
table-create-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table/create/1k duration 120.55 (±2.55 ms) 116.35 (±3.75 ms) -4.2ms (3.5%) 👍
table-update-10th-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table/update-10th/1k duration 81.45 (±2.70 ms) 70.85 (±2.00 ms) -10.6ms (13.0%) 👍
tablecmp-append-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table-component/append/1k duration 231.30 (±11.15 ms) 223.15 (±9.35 ms) -8.2ms (3.5%) 👌
tablecmp-clear-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table-component/clear/1k duration 6.35 (±0.90 ms) 6.30 (±1.00 ms) -0.0ms (0.8%) 👌
tablecmp-create-10k metric base(fee643c) target(6bdcfba) trend
benchmark-table-component/create/10k duration 1774.05 (±14.70 ms) 1742.95 (±10.50 ms) -31.1ms (1.8%) 👍
tablecmp-create-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table-component/create/1k duration 210.75 (±6.50 ms) 208.95 (±5.80 ms) -1.8ms (0.9%) 👍
tablecmp-update-10th-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table-component/update-10th/1k duration 67.90 (±4.15 ms) 67.30 (±4.20 ms) -0.6ms (0.9%) 👌
wc-append-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table-wc/append/1k duration 238.25 (±15.25 ms) 237.50 (±18.30 ms) -0.8ms (0.3%) 👌
wc-clear-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table-wc/clear/1k duration 11.50 (±1.35 ms) 10.75 (±1.55 ms) -0.8ms (6.5%) 👍
wc-create-10k metric base(fee643c) target(6bdcfba) trend
benchmark-table-wc/create/10k duration 1891.95 (±23.40 ms) 1909.15 (±18.85 ms) +17.2ms (0.9%) 👎
wc-create-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table-wc/create/1k duration 220.90 (±7.05 ms) 218.55 (±4.40 ms) -2.3ms (1.1%) 👌
wc-update-10th-1k metric base(fee643c) target(6bdcfba) trend
benchmark-table-wc/update-10th/1k duration 71.00 (±5.15 ms) 67.90 (±4.20 ms) -3.1ms (4.4%) 👍

@caridy
Copy link
Contributor

caridy commented Mar 29, 2019

There are many failures, just make sure that you know what's going on there before merging this.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 5c97354 | Target commit: 017f535

lwc-engine-benchmark

table-append-1k metric base(5c97354) target(017f535) trend
benchmark-table/append/1k duration 155.65 (±5.90 ms) 155.55 (±4.65 ms) -0.1ms (0.1%) 👌
table-clear-1k metric base(5c97354) target(017f535) trend
benchmark-table/clear/1k duration 11.10 (±0.60 ms) 11.10 (±0.75 ms) 0.0ms (0.0%) 👌
table-create-10k metric base(5c97354) target(017f535) trend
benchmark-table/create/10k duration 899.85 (±6.45 ms) 901.05 (±5.20 ms) +1.2ms (0.1%) 👌
table-create-1k metric base(5c97354) target(017f535) trend
benchmark-table/create/1k duration 118.75 (±2.40 ms) 116.55 (±3.75 ms) -2.2ms (1.9%) 👍
table-update-10th-1k metric base(5c97354) target(017f535) trend
benchmark-table/update-10th/1k duration 74.25 (±2.70 ms) 80.35 (±4.70 ms) +6.1ms (8.2%) 👎
tablecmp-append-1k metric base(5c97354) target(017f535) trend
benchmark-table-component/append/1k duration 227.05 (±8.90 ms) 224.40 (±9.55 ms) -2.7ms (1.2%) 👌
tablecmp-clear-1k metric base(5c97354) target(017f535) trend
benchmark-table-component/clear/1k duration 6.15 (±1.00 ms) 6.20 (±1.15 ms) +0.0ms (0.8%) 👌
tablecmp-create-10k metric base(5c97354) target(017f535) trend
benchmark-table-component/create/10k duration 1733.05 (±13.20 ms) 1760.70 (±12.15 ms) +27.6ms (1.6%) 👎
tablecmp-create-1k metric base(5c97354) target(017f535) trend
benchmark-table-component/create/1k duration 210.90 (±6.65 ms) 210.25 (±6.25 ms) -0.6ms (0.3%) 👌
tablecmp-update-10th-1k metric base(5c97354) target(017f535) trend
benchmark-table-component/update-10th/1k duration 68.50 (±3.80 ms) 68.65 (±5.05 ms) +0.2ms (0.2%) 👌
wc-append-1k metric base(5c97354) target(017f535) trend
benchmark-table-wc/append/1k duration 228.60 (±16.15 ms) 231.30 (±20.30 ms) +2.7ms (1.2%) 👌
wc-clear-1k metric base(5c97354) target(017f535) trend
benchmark-table-wc/clear/1k duration 11.10 (±1.50 ms) 11.15 (±1.45 ms) +0.0ms (0.5%) 👌
wc-create-10k metric base(5c97354) target(017f535) trend
benchmark-table-wc/create/10k duration 1909.55 (±18.25 ms) 1905.15 (±18.50 ms) -4.4ms (0.2%) 👌
wc-create-1k metric base(5c97354) target(017f535) trend
benchmark-table-wc/create/1k duration 223.25 (±5.55 ms) 220.15 (±5.05 ms) -3.1ms (1.4%) 👌
wc-update-10th-1k metric base(5c97354) target(017f535) trend
benchmark-table-wc/update-10th/1k duration 68.55 (±4.35 ms) 69.80 (±3.75 ms) +1.3ms (1.8%) 👌

@ravijayaramappa ravijayaramappa merged commit bfb577e into salesforce:master Mar 29, 2019
@ravijayaramappa ravijayaramappa deleted the ravi/master/unify-restriction-descriptors branch March 29, 2019 18:27
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