-
Notifications
You must be signed in to change notification settings - Fork 9k
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 component names case insensitive. ie: getComponent("fooBaR") #3393
Comments
I think this is a very good idea 😄 |
Hi there! I’m a first-time contributor and was hoping to help out with this issue. I noticed nobody was assigned to it, but if there’s already a solution in progress I’m happy to un-assign myself and try helping out elsewhere. Thanks! |
@devthehuman, thanks for checking in! Nobody's working on this, afaik. Feel free to open a pull request that solves this! Comment here if you need any clarification. |
Thanks! Just a quick question about this first bullet point: "When building the system, we store the downcased name of the component in our object." Could you point me in the right direction for where in the build process this should be happening? Is the object you're referring to this base file? |
hey @devthehuman ... the file ( and function, I think ) you're after lies here... https://github.com/swagger-api/swagger-ui/blob/master/src/core/system.js#L285 That function wraps deepExtend, which is how we combine plugins into one largish object. if(isObject(src.components)) { // Bringing in new components?
dest.components = {...dest.components, downcaseThePropsOf(src.components) } // downcaseTheProps doesn't exist btw.
delete src.components // so that we don't add it _again_ later down in this function
} There is likely a prettier way, but that's the safest area to add the code, as it's run when we add stuff to the system ( ie: the big object ). Hope that helps. Stick some console.logs in there to see the stuff that goes through it :) |
@devthehuman, not quite - that file holds the data going into the system 😄 "System" is our name for a structure we use to compile all our plugins and presets into one object that will be used to drive the React app. One part of the object is a Also, for the getting side of things - you'll want to look at the |
I'd like to increase the scope a bit here, due to the issue encountered in #3968.. We should be down casing any usage of component names in |
@shockey I believe there should be a better way; not everyone prefer case-insensitiveness. What about introducing a case check in dev environment and verbose the case miss-match on build. These additional code could be excluded from the production build by setting NODE_ENV and adding if blocks, which will be removed by uglifyjs as dead code; similar way as react remove propsType check. |
The fix for this should be to name components what their actual name is in my opinion. not have this mix of internal names people need to dig through to know that there's a different name for. or actually have a full list of every component where it is easy to find otherwise the Operation class should always work for "Operation". the OperationSummary class should always be referred to as "OperationSummary" it is only the mix of following a convention of getting a component by class name and then some components not being referred to by class name that causes confusion for most developers. I would venture to say that everyone that isn't a dev on this code base would expect you are getting or overriding a react component, it has to follow specific naming conventions to work with JSX and devs are expecting that those conventional names are what you are referring to items with |
Hey Can you assign this to me? I will try to fix the issue |
The plugin system exposes a way to get components via
system.getComponent()
.Up till now its been case sensitive. Unfortunately we never put in a style-guide on what case to use.
So we have lowercase, TitleCase components mixed throughout.
I propose we make them case-insensitive.
eg:
This is to allow any case, and not break any existing code. That said, we should likely normalize the component names in this codebase to be consistent.
Guestimate of work effort: < Normal
@shockey your thoughts?
The text was updated successfully, but these errors were encountered: