-
Notifications
You must be signed in to change notification settings - Fork 392
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
fix: unify the descriptor creation process for restrictions #1144
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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 { |
There was a problem hiding this comment.
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:
function generateDescriptor(options: undefined | object): object { | |
function generateDescriptor(options: PropertyDescriptor): object { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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({ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}```
This comment has been minimized.
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 { |
There was a problem hiding this comment.
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.
function generateDataDescriptor(options: PropertyDescriptor): object { | |
function generateDataDescriptor(options: PropertyDescriptor): PropertyDescriptor { |
This comment has been minimized.
This comment has been minimized.
Benchmark resultsBase commit: lwc-engine-benchmark
|
There are many failures, just make sure that you know what's going on there before merging this. |
Benchmark resultsBase commit: lwc-engine-benchmark
|
Details
Fixes #1124
Does this PR introduce a breaking change?