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

perf: Use weakmap for dom data #6103

Merged
merged 6 commits into from
Aug 1, 2019
Merged

perf: Use weakmap for dom data #6103

merged 6 commits into from
Aug 1, 2019

Conversation

brandonocasey
Copy link
Contributor

Description

Use a weakmap so that we don't have to do the listener removal dance anymore on dispose.

@gkatsev
Copy link
Member

gkatsev commented Jul 18, 2019

Huh, apparently, WeakMap is supported in IE11. Though, it's only basic support, so, we'd want to double check that the operations we are using are supported in IE11.

@@ -250,7 +253,11 @@ export function on(elem, type, fn) {
return _handleMultipleEvents(on, elem, type, fn);
}

const data = DomData.getData(elem);
if (!DomData.has(elem)) {
Copy link
Member

Choose a reason for hiding this comment

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

I see a couple usages of if !has, set, then get. Do you think it's worth a helper?

Copy link
Contributor Author

@brandonocasey brandonocasey Jul 18, 2019

Choose a reason for hiding this comment

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

I think that it might not make sense in this case since it is only used in two places.

EDIT: And the helper name will be likely have to be longer than duplicating the code would be.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, you're right. If we end up with this a few more times, then it'll make sense.

@gkatsev
Copy link
Member

gkatsev commented Jul 29, 2019

This is good to go but I think I'm going to hold off on this to be a minor change.

@gkatsev gkatsev added minor This PR can be added to a minor release. It should not be added to a patch release. confirmed tested labels Jul 29, 2019
@@ -250,7 +253,11 @@ export function on(elem, type, fn) {
return _handleMultipleEvents(on, elem, type, fn);
}

const data = DomData.getData(elem);
if (!DomData.has(elem)) {
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, you're right. If we end up with this a few more times, then it'll make sense.

@gkatsev gkatsev merged commit 8610f99 into master Aug 1, 2019
@gkatsev gkatsev deleted the perf/use-weakmap branch August 1, 2019 18:27
gkatsev pushed a commit that referenced this pull request Sep 5, 2019
…me people have relied on this (#6216)

When a player is created without an id on the embed code, Video.js automatically assigns it one based on an auto-incrementing number (a.k.a. a GUID). For the longest time, this has happened to result in the default id of the first player being vjs_video_3.

It was never intended for users to rely on this value being consistent, but users do strange and inadvisable things.

PR #6103 had an unintended side effect in that it changed the default id to vjs_video_2, which we worry could affect some users of Video.js.
@wind-stone
Copy link

Rollup did't compiler the WeapMap, as a result, there is an error "WeapMap is undefined" in Android 4.x

@gkatsev
Copy link
Member

gkatsev commented Oct 10, 2019

@wind-stone thanks for bringing it up. We'll work on figuring out how to make it better.

@gkatsev
Copy link
Member

gkatsev commented Oct 28, 2019

I have a PR to fix this pending here #6289

@gkatsev
Copy link
Member

gkatsev commented Nov 7, 2019

We merged #6289 and will be releasing it soon.

gkatsev pushed a commit that referenced this pull request Nov 7, 2019
…me people have relied on this (#6216)

When a player is created without an id on the embed code, Video.js automatically assigns it one based on an auto-incrementing number (a.k.a. a GUID). For the longest time, this has happened to result in the default id of the first player being vjs_video_3.

It was never intended for users to rely on this value being consistent, but users do strange and inadvisable things.

PR #6103 had an unintended side effect in that it changed the default id to vjs_video_2, which we worry could affect some users of Video.js.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed minor This PR can be added to a minor release. It should not be added to a patch release. tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants