Skip to content

Commit 8cfa60e

Browse files
committed
Fixed regex: now accepts 1-letter attributes
Fixed htmlparser.js so that attributes whose name is just one letter are accepted. For instance <rect x="50" y="20" width="150" height="150"> wasn't recognized, despite of being formally correct: the regular expression stopped before "x="
1 parent e2e19cd commit 8cfa60e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

htmlparser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
(function () {
3232

3333
// Regular Expressions for parsing tags and attributes
34-
var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
34+
var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
3535
endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/,
36-
attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
36+
attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
3737

3838
// Empty Elements - HTML 5
3939
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");

0 commit comments

Comments
 (0)