jonkemp / inline-css

Inline css into an html file.
MIT License
429 stars 85 forks source link

Bug | Pseudo Check (Sanity required) #105

Open clizSec opened 3 years ago

clizSec commented 3 years ago

At the pseudoCheck.js library's code, at line 25, need to add an extra sanity (or before), as stylesheet like the following below, will break it:

<style>, something { font-size: 12px; } p { font-color: red; } a { margin: 0.1em; }</style>

This is because of the comma (,) before the something element is presented with his styles, the library will try to parse that, and will return an array with first element index as empty string, and second, with the CSS object structure.

Screenshot explained:

webstorm64_t3HxuRRRjD inline-css.js

With an error of:

TypeError: Cannot read property 'length' of undefined
    at module.exports (D:\XYZ\WebstormProjects\TestApp\node_modules\inline-css\lib\pseudoCheck.js:27:36)
    at D:\XYZ\WebstormProjects\TestApp\node_modules\inline-css\lib\inline-css.js:72:26
    at Array.forEach (<anonymous>)
    at module.exports (D:\XYZ\WebstormProjects\TestApp\node_modules\inline-css\lib\inline-css.js:68:11)
    at D:\WebstormProjects\TestApp\node_modules\inline-css\lib\inlineContent.js:22:27
    at D:\XYZ\WebstormProjects\TestApp\node_modules\extract-css\index.js:37:16
    at D:\XYZ\WebstormProjects\TestApp\node_modules\batch\index.js:161:14
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

webstorm64_xg6NRJjpMd pseudoCheck.js