Allow css vars with uppercase characters (#2311)
* Allow css vars with uppercase characters * Remove charAt * Extract dash lowercase lambda * Extract match uppercase regex * Set key and value correctly in updateStyle * Fix domMock style to work like the browser
This commit is contained in:
parent
87033bf1e0
commit
7c299ab48c
3 changed files with 34 additions and 19 deletions
|
|
@ -220,6 +220,9 @@ module.exports = function(options) {
|
|||
parseMarkup(value, root, [], "http://www.w3.org/2000/svg")
|
||||
return {documentElement: root}
|
||||
}
|
||||
function camelCase(string) {
|
||||
return string.replace(/-\D/g, function(match) {return match[1].toUpperCase()})
|
||||
}
|
||||
var activeElement
|
||||
var $window = {
|
||||
DOMParser: DOMParser,
|
||||
|
|
@ -240,10 +243,10 @@ module.exports = function(options) {
|
|||
var colonIndex = rule.indexOf(":")
|
||||
if (colonIndex > -1) {
|
||||
var rawKey = rule.slice(0, colonIndex).trim()
|
||||
var key = rawKey.replace(/-\D/g, function(match) {return match[1].toUpperCase()})
|
||||
var key = camelCase(rawKey)
|
||||
var value = rule.slice(colonIndex + 1).trim()
|
||||
if (key !== "cssText") {
|
||||
style[key] = value
|
||||
style[key] = style[rawKey] = value
|
||||
buf.push(rawKey + ": " + value + ";")
|
||||
}
|
||||
}
|
||||
|
|
@ -256,10 +259,10 @@ module.exports = function(options) {
|
|||
return style[key]
|
||||
}},
|
||||
removeProperty: {value: function(key){
|
||||
style[key] = ""
|
||||
style[key] = style[camelCase(key)] = ""
|
||||
}},
|
||||
setProperty: {value: function(key, value){
|
||||
style[key] = value
|
||||
style[key] = style[camelCase(key)] = value
|
||||
}}
|
||||
})
|
||||
var events = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue