Skip to content

Commit 75cb290

Browse files
committed
(fix) refine attributeRegex
Fix attributeRegex that correctly match attributes that are not enclosed in quotes. fix sveltejs#344
1 parent 3a353ab commit 75cb290

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/extractAttributes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AttributeNode, TextNode } from '../print/nodes';
22

33
export function extractAttributes(html: string): AttributeNode[] {
44
const extractAttributesRegex = /<[a-z]+[\s\n]*([\s\S]*?)>/im;
5-
const attributeRegex = /([^\s=]+)(?:=("|')([\s\S]*?)\2)?/gim;
5+
const attributeRegex = /([^\s=]+)(?:=("|')([\s\S]*?)\2)?(?: |$)/gim;
66

77
const [, attributesString] = html.match(extractAttributesRegex)!;
88

0 commit comments

Comments
 (0)