Skip to content

refactor: Add isString #8038

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

refactor: Add isString #8038

wants to merge 2 commits into from

Conversation

243083df
Copy link

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

@@ -499,7 +499,7 @@ function genProps (props: Array<{ name: string, value: any }>): string {

/* istanbul ignore next */
function generateValue (value) {
if (typeof value === 'string') {
if (isString(value)) {
Copy link

Choose a reason for hiding this comment

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

What do you think about return isString(value) ? transformSpecialNewlines(value) : JSON.stringify(value) notation ?

@dsonet
Copy link
Contributor

dsonet commented Apr 18, 2018

Is this really needed or something just more like over-engineering?

@lusarz
Copy link

lusarz commented Apr 22, 2018

For me it's good approach to create isString like methods. It increases readability of code.

There are methods like isTrue, isFalse, isObject in shared/util, so why don't create similar for isString ?

Please also take a look here:
https://github.com/vuejs/vue/blob/f7b5c86ef2620c1d7ec275f86ae0f380ccaea4ef/src/platforms/web/util/class.js#L37-L39
Mixing different levels of abstraction (isObject near typeof value === 'string') is not a good practice.

@243083df
Copy link
Author

243083df commented May 8, 2018

As said lusarz, there is methods like isTrue|isFalse|isObject|isPrimitive, so i dont see over-engineering here

Copy link

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

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

You need to resolve merge conflicts.

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