Bypass css text (#2811)
* [DOM mocks] enable setting element.style * Use the style setter directly
This commit is contained in:
parent
645cf663b2
commit
c1fc1de772
3 changed files with 9 additions and 13 deletions
|
|
@ -346,9 +346,8 @@ module.exports = function(options) {
|
|||
get style() {
|
||||
return style
|
||||
},
|
||||
set style(_){
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style#Setting_style
|
||||
throw new Error("setting element.style is not portable")
|
||||
set style(value){
|
||||
this.style.cssText = value
|
||||
},
|
||||
get className() {
|
||||
return this.attributes["class"] ? this.attributes["class"].value : ""
|
||||
|
|
|
|||
|
|
@ -665,16 +665,13 @@ o.spec("domMock", function() {
|
|||
o(div.style.background).equals("url('/*foo*/')")
|
||||
|
||||
})
|
||||
o("setting style throws", function () {
|
||||
o("setting style updates style.cssText", function () {
|
||||
var div = $document.createElement("div")
|
||||
var err = false
|
||||
try {
|
||||
div.style = ""
|
||||
} catch (e) {
|
||||
err = e
|
||||
}
|
||||
div.style = "background: red;"
|
||||
|
||||
o(div.style.background).equals("red")
|
||||
o(div.style.cssText).equals("background: red;")
|
||||
|
||||
o(err instanceof Error).equals(true)
|
||||
})
|
||||
})
|
||||
o.spec("events", function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue