generated from sonofmagic/monorepo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Bug with utility class which contains trailing slash #24
regex should exact match class str
- Loading branch information
1 parent
29e96df
commit 9d5308f
Showing
16 changed files
with
477 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,5 +44,8 @@ | |
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"vitest": "^0.32.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`html handler > common usage 1`] = ` | ||
"<!DOCTYPE html><html><head> | ||
<meta charset=\\"UTF-8\\"> | ||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\"> | ||
<link href=\\"/main.css\\" rel=\\"stylesheet\\"> | ||
</head> | ||
<body> | ||
<h1 class=\\"tw-a tw-b tw-c\\"> | ||
Hello world! | ||
</h1> | ||
</body></html>" | ||
`; | ||
exports[`html handler > trailing slash case 1`] = ` | ||
"<!DOCTYPE html><html lang=\\"en\\"><head> | ||
<meta charset=\\"UTF-8\\"> | ||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"IE=edge\\"> | ||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div> | ||
<div class=\\"tw-a\\"> | ||
Block with bg-red-500 class | ||
</div> | ||
<div class=\\"tw-b\\"> | ||
Block with bg-red-500/50 class | ||
</div> | ||
</div> | ||
</body></html>" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
document.getElementById('#app').classList.add('bg-red-500 bg-red-500/50') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<div class="bg-red-500"> | ||
Block with bg-red-500 class | ||
</div> | ||
<div class="bg-red-500/50"> | ||
Block with bg-red-500/50 class | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getTestCase } from './utils' | ||
import { htmlHandler } from '../src/html' | ||
import { ClassGenerator, splitCode } from 'tailwindcss-mangle-shared' | ||
import { describe, it, beforeEach, expect } from 'vitest' | ||
describe('html handler', () => { | ||
let classGenerator: ClassGenerator | ||
beforeEach(() => { | ||
classGenerator = new ClassGenerator() | ||
}) | ||
it('common usage', () => { | ||
const runtimeSet = new Set<string>() | ||
|
||
splitCode('text-3xl font-bold underline').forEach((x) => { | ||
runtimeSet.add(x) | ||
}) | ||
const res = htmlHandler(getTestCase('hello-world.html'), { | ||
classGenerator, | ||
runtimeSet | ||
}) | ||
expect(res).toMatchSnapshot() | ||
}) | ||
|
||
it('trailing slash case', () => { | ||
const runtimeSet = new Set<string>() | ||
|
||
splitCode('bg-red-500 bg-red-500/50').forEach((x) => { | ||
runtimeSet.add(x) | ||
}) | ||
const res = htmlHandler(getTestCase('trailing-slash.html'), { | ||
classGenerator, | ||
runtimeSet | ||
}) | ||
expect(res).toMatchSnapshot() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
test: { | ||
include: ['test/html.test.ts'] | ||
// ... | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/tailwindcss-patch/test/fixtures/trailing-slash.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<div> | ||
<div class=""> | ||
<div class=""> | ||
<div class="bg-[#2f2f2f]"> | ||
<div class="bg-red-500"> | ||
Block with bg-red-500 class | ||
</div> | ||
<div class="bg-red-500/50"> | ||
Block with bg-red-500/50 class | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
Oops, something went wrong.