mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
45c665d396
commit
00e00da233
2 changed files with 3 additions and 1 deletions
|
@ -220,6 +220,7 @@ func isQuote(b byte) bool {
|
||||||
var (
|
var (
|
||||||
htmlJsonFixer = strings.NewReplacer(", ", "\n")
|
htmlJsonFixer = strings.NewReplacer(", ", "\n")
|
||||||
jsonAttrRe = regexp.MustCompile(`'?(.*?)'?:.*`)
|
jsonAttrRe = regexp.MustCompile(`'?(.*?)'?:.*`)
|
||||||
|
classAttrRe = regexp.MustCompile(`(?i)^class$|transition`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseHTMLElement(elStr string) (el htmlElement) {
|
func parseHTMLElement(elStr string) (el htmlElement) {
|
||||||
|
@ -242,7 +243,7 @@ func parseHTMLElement(elStr string) (el htmlElement) {
|
||||||
// There should be only one, but one never knows...
|
// There should be only one, but one never knows...
|
||||||
el.IDs = append(el.IDs, a.Val)
|
el.IDs = append(el.IDs, a.Val)
|
||||||
default:
|
default:
|
||||||
if strings.EqualFold(a.Key, "class") {
|
if classAttrRe.MatchString(a.Key) {
|
||||||
el.Classes = append(el.Classes, strings.Fields(a.Val)...)
|
el.Classes = append(el.Classes, strings.Fields(a.Val)...)
|
||||||
} else {
|
} else {
|
||||||
key := strings.ToLower(a.Key)
|
key := strings.ToLower(a.Key)
|
||||||
|
|
|
@ -85,6 +85,7 @@ func TestClassCollector(t *testing.T) {
|
||||||
|
|
||||||
}" class="block w-36 cursor-pointer pr-3 no-underline capitalize"></a>`, f("a", "block capitalize cursor-pointer no-underline pl-2 pl-3 pr-3 text-a text-b text-gray-600 w-36", "")},
|
}" class="block w-36 cursor-pointer pr-3 no-underline capitalize"></a>`, f("a", "block capitalize cursor-pointer no-underline pl-2 pl-3 pr-3 text-a text-b text-gray-600 w-36", "")},
|
||||||
|
|
||||||
|
{"Alpine transition 1", `<div x-transition:enter-start="opacity-0 transform mobile:-translate-x-8 sm:-translate-y-8">`, f("div", "mobile:-translate-x-8 opacity-0 sm:-translate-y-8 transform", "")},
|
||||||
{"Vue bind", `<div v-bind:class="{ active: isActive }"></div>`, f("div", "active", "")},
|
{"Vue bind", `<div v-bind:class="{ active: isActive }"></div>`, f("div", "active", "")},
|
||||||
} {
|
} {
|
||||||
c.Run(test.name, func(c *qt.C) {
|
c.Run(test.name, func(c *qt.C) {
|
||||||
|
|
Loading…
Reference in a new issue