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

refactor(engine): remove Event instanceof check on dispatchEvent #1648

Merged
merged 3 commits into from
Jan 8, 2020

Conversation

pmdartus
Copy link
Member

Details

In the process of implementing SSR (#910), to start decoupling the engine from the DOM. This PR remove the instanceof Event check in LigthningElement.prototype.dispatchEvent. The same check is run by the browser when invoking the EventTarget.prototype.dispatchEvent method.

Does this PR introduce breaking changes?

  • No, it does not introduce breaking changes.

If yes, please describe the impact and migration path for existing applications.

The PR fulfills these requirements:

  • Have tests for the proposed changes been added? ✅
  • Have you followed these instructions to clearly describe the issue being fixed or feature enhanced? ✅

@pmdartus pmdartus requested a review from caridy December 12, 2019 14:07
@pmdartus
Copy link
Member Author

Discussion with @caridy:

  • The 2 checks below the code change need to move to the restrictions.ts
  • Convert .call to .apply to preserve the number of args
  • Remove the first check in the method, no longer needed.

@pmdartus pmdartus changed the title chore(engine): remove Event instanceof check on dispatchEvent refactor(engine): remove Event instanceof check on dispatchEvent Dec 13, 2019
@pmdartus pmdartus requested a review from caridy December 13, 2019 08:02
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.

few changes needed

if (!isNull(event) && isObject(event)) {
const { type } = event;

if (isString(type) && !/^[a-z][a-z0-9_]*$/.test(type)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this condition is incorrect, type should be a string, and a valid one, otherwise throw.

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.

one minor detail on the restriction condition.

@pmdartus pmdartus requested a review from caridy January 6, 2020 12:55
@pmdartus
Copy link
Member Author

pmdartus commented Jan 6, 2020

@caridy Ready for another pass of review.

@pmdartus pmdartus merged commit 684b883 into master Jan 8, 2020
@pmdartus pmdartus deleted the pmdartus/remove-instance-of branch January 8, 2020 12:24
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