← 输入框|github.com|刷新
Skip to content

Nativescript Ignores CSS Class Names Separated By Newlines #9402

Closed

Description

@joshmossas-old

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI:
  • Cross-platform modules:
  • Android Runtime:
  • iOS Runtime:
  • XCode Version:
  • Plugin(s):

Describe the bug
In my Nativescript-Vue project, Nativescript will ignore HTML class names when they span across multiple lines.

<!-- this works -->
<Button 
  text="My Button"
  class="font-bold mt-10 p-4 text-base bg-primary-600 text-white"
/>

<!-- this doesn't work -->
<Button
  text="My Button"
  class="
    font-bold
    mt-10
    p-4
    text-base
    bg-primary-600
    text-white
  "
/>

To Reproduce
Create an element in your project that has the class names formatted like above.

Expected behavior
Multiline HTML class property works in all the major browsers no problem - you can basically use any number of whitespace characters between class names. Since Nativescript tries to emulates CSS conventions it should try to reproduce the way HTML classes are typically parsed. This will ensure consistent behavior for things like auto-formatters and parsers (in my case the newest version of Prettier is now unusable with Nativescript. See below.)

Sample project
N/A

Additional context
I ran into this bug when I upgraded prettier to v2.3. In the latest version they changed the way they handle the HTML class property (see details here). To summarize the change, css classes are kept on a single line up until the line length limit is reached after which it will break the css classes into multiple lines.

Once I upgraded prettier, it ended up reformatting the css classes across the project and breaking my styles (I'm using tailwind so you can imagine this happened in a lot of places). I have since reverted back to prettier v2.x.x until it's safe to upgrade.

Cheers

Activity

  1. changed the title [-]Nativescript Ignores Multiline Class Names on Multiple Lines[/-] [+]Nativescript Ignores CSS Classes on Multiple Lines[/+] on May 16, 2021
  2. changed the title [-]Nativescript Ignores CSS Classes on Multiple Lines[/-] [+]Nativescript Ignores CSS Class Names Separated By Newlines[/+] on May 16, 2021
  3. added a commit that references this issue on Oct 28, 2026
    16d8ef1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions