question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

make component names case insensitive. ie: getComponent("fooBaR")

See original GitHub 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.

  • When building the system, we store the downcased name of the component in our object.
  • When fetching, we downcase the argument to getComponent in order to fetch it from our object.

eg:

//...
plugins = [ { components: { wONderBAR: () => <h1> Hi </h1> } } ]
// stored as  { wonderbar: .... }

system.getComponent("wonderBAR") // the component keyed with "wonderbar"

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?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ponelatcommented, Jul 18, 2017

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. The code to be added there would look something like…

 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 😃

1reaction
shockeycommented, Jul 15, 2017

I think this is a very good idea 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Request] Option for case insensitive search - HydrogenAudio
2) Double click on part of the band name, Ctrl+C ... However just the 'case insensitive' search may also do.
Read more >
c preprocessor - Case insensitive #define - Stack Overflow
The reason behind this is that I want to #define some fortran subroutines to have different names, and they of course are case...
Read more >
Style Guide - Vue.js
Component names should always be multi-word, except for root App ... However, mixed case filenames can sometimes create issues on case-insensitive file ...
Read more >
case-insensitive - IBM
For a case-sensitive match when the value for the value command is ^foo , only values that start with foo match. In other...
Read more >
11.5. Package Case-Sensitivity - CLISP - SourceForge
For example, with case sensitive symbols, the symbols cdr (the function ... when printing the SYMBOL-NAME part of a SYMBOL (i.e. the part...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found