posthtml / htmlnano

Modular HTML minifier, built on top of the PostHTML

Home Page:https://htmlnano.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`x-intersect:enter` attribute on SVG triggers `Cannot read properties of undefined (reading 'attrs')`

mischnic opened this issue · comments

x-intersect:enter is used by Alpine.JS: https://alpinejs.dev/plugins/intersect

Error:

Uncaught TypeError: Cannot read properties of undefined (reading 'attrs')
    at node_modules/htmlnano/lib/modules/sortAttributesWithLists.js:77:15
    at traverse (node_modules/posthtml/lib/api.js:105:26)
    at traverse (node_modules/posthtml/lib/api.js:111:5)
    at traverse (node_modules/posthtml/lib/api.js:105:17)
    at Array.walk (node_modules/posthtml/lib/api.js:39:10)
    at sortAttributesWithListsInAlphabeticalOrder (node_modules/htmlnano/lib/modules/sortAttributesWithLists.js:76:8)
    at Object.collapseAttributeWhitespace [as default] (node_modules/htmlnano/lib/modules/sortAttributesWithLists.js:64:12)

Reproduction:

await require("htmlnano").process(
   `<svg viewBox="0 0 430 225" x-data="{shown: false}" x-intersect:enter="shown = true"></svg>`,
   {minifyJs: false, minifyCss: false}
)

Using version 2.0.2

commented

@mrmlnc The issue has already been fixed in the master branch. However, htmlnano hasn't released any version since May.

I just released a new version: 2.0.3