Coder Social home page Coder Social logo

Comments (10)

Daniel15 avatar Daniel15 commented on May 2, 2024

Good catch, we probably need to special-case line-height. May need some special case here: https://github.com/reactjs/react-magic/blob/master/src/htmltojsx.js#L127-L129

from react-magic.

Daniel15 avatar Daniel15 commented on May 2, 2024

Should determine where React pulls this blacklist from: http://facebook.github.io/react/tips/style-props-value-px.html

from react-magic.

ssorallen avatar ssorallen commented on May 2, 2024

@Daniel15 Why modify those values at all? React 16 will stop appending 'px' for CSS values, so that modification will potentially break. Can HTMLtoJSX simply use the values verbatim?

from react-magic.

ssorallen avatar ssorallen commented on May 2, 2024

https://facebook.github.io/react/blog/2016/04/07/react-v15.html#new-helpful-warnings

React DOM: When specifying a unit-less CSS value as a string, a future version will not add px automatically.

from react-magic.

Daniel15 avatar Daniel15 commented on May 2, 2024

@ssorallen - That changelog entry only applies to strings (eg. {{width: '123'}}, not numbers (eg. {{width: 123}}). The behaviour for numbers remains unchanged.

Having said that, there's no harm in keeping the px suffix, so maybe HTMLtoJSX should just use it verbatim.

from react-magic.

sizer avatar sizer commented on May 2, 2024

any news about this issue?

from react-magic.

Daniel15 avatar Daniel15 commented on May 2, 2024

@mrdShinse I don't think anyone has submitted a PR to fix it yet

from react-magic.

drax10 avatar drax10 commented on May 2, 2024

@ssorallen - That changelog entry only applies to strings (eg. {{width: '123'}}, not numbers (eg. {{width: 123}}). The behaviour for numbers remains unchanged.

Having said that, there's no harm in keeping the px suffix, so maybe HTMLtoJSX should just use it verbatim.

If this is the case, this can be solved simply by removing these lines https://github.com/reactjs/react-magic/blob/master/src/htmltojsx.js#L727-L729 along with the isConvertiblePixelValue function. Please advise if I'm missing some reason some styles need the px suffix omitted.

from react-magic.

SkyzohKey avatar SkyzohKey commented on May 2, 2024

ESLint rule so this behavior can be prevented.

{
  ...
  "rules": {
    "no-restricted-syntax": [
      "error",
      {
        "selector": "Property[key.name=lineHeight] > Literal[value=/([0-9]+)[^px]$/]",
        "message": "Make sure to specify an unit when using lineHeight (see React issue: https://github.com/reactjs/react-magic/issues/53)"
      }
    ]
  }
}

from react-magic.

zomars avatar zomars commented on May 2, 2024

I'm willing to make a PR if someone can tell me where I can add an exception for line-height.

EDIT: I see that you have this method to strip px values but I can't where is being used:

function isConvertiblePixelValue(value) {

from react-magic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.