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

Make initListeners more general. #2773

Closed
wants to merge 17 commits into from

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented Nov 3, 2015

Also, look in the component's options themselves and not just children
for components to initialize.

Fixes #2767, has issues around #2772.

Also, look in the component's options themselves and not just children
for components to initialize.
@@ -369,6 +369,10 @@ class Component {
// If there's no .player_, this is a player
let ComponentClass = Component.getComponent(componentClassName);

if (!ComponentClass) {
Copy link
Member Author

Choose a reason for hiding this comment

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

abort trying to make a component if it doesn't exist.

Copy link
Member

Choose a reason for hiding this comment

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

Should this throw an exception instead?

Copy link
Member

Choose a reason for hiding this comment

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

Elaborating a bit-- if a bad component was encountered midway through player creation, this would abort early and return a player missing a chunk of itself. It seems like a bad component name is a development-time-misconfiguration and it might be better to fail fast and force a fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Children could also, theoretically, be configured dynamically, in which case, we possibly don't want to throw.
However, now that I'm making sure that everything is a component below, I guess I probably don't even need to have this section here and leave it as what it was.

@pam
Copy link

pam commented Nov 3, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 13f524c
Build details: https://travis-ci.org/pam/video.js/builds/89085787

(Please note that this is a fully automated comment.)

}

workingChildren.concat(Object.getOwnPropertyNames(this.options_))
Copy link
Member Author

Choose a reason for hiding this comment

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

workingChildren is either the array of children or a list of the object properties from the children object.
We then want to concatenate it with the list of all names from options, since that could contain other children we want to add.

@pam
Copy link

pam commented Nov 3, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: a543d4d
Build details: https://travis-ci.org/pam/video.js/builds/89086398

(Please note that this is a fully automated comment.)

}

workingChildren.concat(Object.getOwnPropertyNames(this.options_))
.map((child) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

get everything into the same format of [{name, options}, ...]

// See https://github.com/videojs/video.js/issues/2772
let c = Component.getComponent(child.opts.componentClass ||
toTitleCase(child.name));
return c && !Tech.isTech(c);
Copy link
Member Author

Choose a reason for hiding this comment

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

Ignore techs and not components. Techs need to be ignored specifically because of #2772.

@pam
Copy link

pam commented Nov 3, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 8000460
Build details: https://travis-ci.org/pam/video.js/builds/89089642

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Nov 3, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 1c82bc9
Build details: https://travis-ci.org/pam/video.js/builds/89087416

(Please note that this is a fully automated comment.)

@gkatsev
Copy link
Member Author

gkatsev commented Nov 3, 2015

It's failing in IE9 and 10 because those don't have Object.getPrototypeOf. Looking for an alternative.

@pam
Copy link

pam commented Nov 3, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 80c5172
Build details: https://travis-ci.org/pam/video.js/builds/89099542

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Nov 3, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: b4bc4b8
Build details: https://travis-ci.org/pam/video.js/builds/89101186

(Please note that this is a fully automated comment.)

Object.getOwnPropertyNames(children).forEach(function(name){
handleAdd(name, children[name]);
});
workingChildren = Object.getOwnPropertyNames(children);
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiousity, is there a reason we're using Object.getOwnPropertyNames instead of Object.keys in many/most places (not just this PR)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure.

Copy link
Member

Choose a reason for hiding this comment

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

It's pretty much an incidental difference for our purposes: keys includes only enumerable properties where getOwnPropertyNames includes non-enumerable properties.

Copy link
Member

Choose a reason for hiding this comment

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

Seems like keys would be the right mechanism here to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Switched to use keys.

@pam
Copy link

pam commented Nov 3, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 59a509e
Build details: https://travis-ci.org/pam/video.js/builds/89125066

(Please note that this is a fully automated comment.)

@gkatsev
Copy link
Member Author

gkatsev commented Nov 4, 2015

@pam retry

@pam
Copy link

pam commented Nov 4, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 59a509e
Build details: https://travis-ci.org/pam/video.js/builds/89127221

(Please note that this is a fully automated comment.)

@gkatsev
Copy link
Member Author

gkatsev commented Nov 4, 2015

@pam retry

@pam
Copy link

pam commented Nov 4, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 59a509e
Build details: https://travis-ci.org/pam/video.js/builds/89128366

(Please note that this is a fully automated comment.)

@misteroneill
Copy link
Member

No tests? 😄

@gkatsev
Copy link
Member Author

gkatsev commented Nov 4, 2015

@misteroneill what are tests? :P
Yeah, I guess I should add some.

@pam
Copy link

pam commented Nov 4, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: bfeb3a4
Build details: https://travis-ci.org/pam/video.js/builds/89292637

(Please note that this is a fully automated comment.)

@misteroneill
Copy link
Member

Do we have sufficient coverage for the various permutations of children on components?

@gkatsev
Copy link
Member Author

gkatsev commented Nov 4, 2015

I'm updating tests for that currently. Currently there's an issue where you might end up with two components if add settings to a component (rather than disabling it).

We don't want to actually run uniq because if the childrens array has
multiple items, we do want multiple items in that case. However, we
don't want to add more children of a kind if it is also available in
options. So, we filter those out.
@gkatsev gkatsev mentioned this pull request Nov 5, 2015
@pam
Copy link

pam commented Nov 5, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 2056048
Build details: https://travis-ci.org/pam/video.js/builds/89505144

(Please note that this is a fully automated comment.)

@misteroneill
Copy link
Member

LGTM!

@@ -521,33 +528,65 @@ class Component {
// Add a direct reference to the child by name on the parent instance.
// If two of the same component are used, different names should be supplied
// for each
this[name] = this.addChild(name, opts);
let newChild = this.addChild(name, opts);
if (newChild) {
Copy link
Member

Choose a reason for hiding this comment

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

If you agree with my suggestion above, this part could be reverted.

@pam
Copy link

pam commented Nov 6, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 88f92b0
Build details: https://travis-ci.org/pam/video.js/builds/89707197

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Nov 6, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: a1583ee
Build details: https://travis-ci.org/pam/video.js/builds/89715046

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Nov 6, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 6bf3bb4
Build details: https://travis-ci.org/pam/video.js/builds/89725739

(Please note that this is a fully automated comment.)

@gkatsev
Copy link
Member Author

gkatsev commented Nov 6, 2015

@pam retry

@dmlap
Copy link
Member

dmlap commented Nov 6, 2015

Had a discussion about reducing the calculation of workingChildren a bit but otherwise LGTM

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.

4 participants