Skip to content

Commit

Permalink
fix: Trim white space in HTML attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvsde committed Jan 13, 2020
1 parent 34d8150 commit 1f74d40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/utils/prettify-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function parse (text, { html }) {
forEachDeep(ast, 'children', item => {
if (item.attrs) {
item.attrs.forEach(attr => {
attr.value = attr.value && attr.value.replace(/\s+/g, ' ')
attr.value = attr.value && attr.value.trim().replace(/\s+/g, ' ')
})
}
})
Expand Down
3 changes: 2 additions & 1 deletion test/unit/lib/utils/fixtures/prettify-render.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<img
alt="Lorem ipsum dolor sit amet"
src=""
class="hello
class="
hello
world
js-different-thing-img"
Expand Down

0 comments on commit 1f74d40

Please sign in to comment.