-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Restore some globals #2311
Comments
One of the main benefits is that it allows us to better encapsulate the internal modules and not have circular dependencies. |
I think you dodged the question :) Why shouldn't it be encouraged or supported? |
When switching to modules this was our major circular dependency. Component children were added by name off the videojs object. In Component, The solution was to make it so Component didn't look for other components on It doesn't have to be a function. We could have other components just add themselves to Component.components, and the export components, |
I'm gonna close this since it's a question but we can continue to discuss and reopen if a change is decided on. |
Also, knowing when a component registered with us could be beneficial. Don't really have anything else in mind right now but we could add other functionality around it at a later date without making it a breaking change. If Users just add it directly to the Also, this falls under the "don't modify objects you don't own" mantra we should be striving for. Users of videojs don't own the videojs object, so, they shouldn't be adding random properties to it themselves. |
I'm don't quite follow the circular dependency issue but I'll trust you on that one. I think registering components as |
We shouldn't encourage users to modify objects they didn't create themselves. |
I don't really understand that objection. What is the difference between a function whose only purpose is to modify state and just telling users how to directly modify state? getBlah(), listBlah(), setBlah() seem like the J2EE solution to this problem. |
I have been kind of skirting the issue because I wasn't sure how to say what I thought. But hopefully I've collected my thoughts enough so the following is intelligible. There are several reasons why having a few simple functions for getting and registering the components is beneficial over just having users attach it to our object. In summary, having these functions allows us to have better, safer code that we can modify with more freedom without having to worry about whether we're going to break anyone. |
Thanks for the thoughtful response, @gkatsev. I still don't think making this change at this point is a good thing. Here's my reasoning:
If it weren't for the backward compatibility issue, I probably would agree with you. video.js is used on a lot of sites nowadays though and I think we need to have a higher bar for removing popular APIs. |
|
I think global options should be restored as well. It's another API breakage and given it's returning a shared, mutable object anyways the indirection is confusing. |
Based on the discussion above, I'm reopening this to restore |
Ok by me |
We should consider logging a deprecation warning for the usage. |
Using a proxy? Is that supported places now? |
Probably using getters/setters and the el trick for IE8. |
Both objects have arbitrary keys, so it seems like that would get pretty complicated. |
Well, for players, we're only ever setting it in one place, so, that shouldn't be too hard. |
Got it. Works for me. Doesn't have to work everywhere in my opinion, just somewhere a dev will likely see it. i.e. no need for a shim for IE8. |
if no shim for ie8, even better. However, some users still use |
I'm just saying if it's IE8 we leave players/options alone, and not worry about adding an observer to throw a deprecation warning. I doubt there's cases where they'd only see the deprecation warning in IE8. |
Oh, deprecation warning. I guess we were talking past each other. Yeah, I'm ok with leaving it out from IE8 if it isn't super easy to do. |
I like the idea of using Re-exposing |
Why would it trigger warning for legitimate uses? There are no "legitimate" uses for the deprecated properties. |
Because, for example, constructing a One solution might be to expose |
Ah, I see. I'm saying |
I see what you're saying, but I think I'm going to see what I can do with the |
I think the proxy approach won't give us the browser support we would want. |
In what way? The only limitation I see is that browsers that don't support |
Maybe we're talking past each other. Would the Proxy be using just for the deprecation warning? |
Yeah, that's the idea. Sorry if it wasn't clear! I'll have a commit for preliminary review momentarily. |
No worries. Just using it for deprecation warning is fine by mean. I see what you mean about "legitimate" cases now. |
Here's the sort of thing I'm thinking. |
I believe this has been fully addressed at this point with #2395. Let me know if you think otherwise.
|
It seems like they just save and retrieve the component from a private variable. Any background on why this change was made? Besides making it a bit more verbose to reference things like the techs it also makes enumerating available components seem like something that is discouraged.
The text was updated successfully, but these errors were encountered: