#1080 parse pattern attribute correctly
This commit is contained in:
parent
b128fd8232
commit
80349b3c74
4 changed files with 10 additions and 6 deletions
|
|
@ -84,7 +84,7 @@
|
|||
|
||||
function parseTagAttrs(cell, tag) {
|
||||
var classes = []
|
||||
var parser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g
|
||||
var parser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g
|
||||
var match
|
||||
|
||||
while ((match = parser.exec(tag))) {
|
||||
|
|
@ -95,8 +95,9 @@
|
|||
} else if (match[1] === ".") {
|
||||
classes.push(match[2])
|
||||
} else if (match[3][0] === "[") {
|
||||
var pair = /\[(.+?)(?:=("|'|)(.*?)\2)?\]/.exec(match[3])
|
||||
cell.attrs[pair[1]] = pair[3] || ""
|
||||
var attrValue = match[6]
|
||||
if (attrValue) attrValue = attrValue.replace(/\\(["'])/g, "$1")
|
||||
cell.attrs[match[4]] = attrValue || ""
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
4
mithril.min.js
vendored
4
mithril.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -48,6 +48,9 @@ describe("m()", function () {
|
|||
it("sets correct double quoted attr", function () {
|
||||
expect(m("[title=\"bar\"]")).to.have.deep.property("attrs.title", "bar")
|
||||
})
|
||||
it("sets pattern attr", function () {
|
||||
expect(m("[pattern=\"[a-zA-Z0-9]{56}\"]")).to.have.deep.property("attrs.pattern", "[a-zA-Z0-9]{56}")
|
||||
})
|
||||
|
||||
it("sets correct children with 1 string arg", function () {
|
||||
expect(m("div", "test"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue