forked from jsdom/cssstyle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
34 lines (26 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const webidlWrapper = require('./webidl2js-wrapper.js')
const sharedGlobalObject = {}
webidlWrapper.install(sharedGlobalObject, ['Window'])
const origCSSStyleDeclaration = sharedGlobalObject.CSSStyleDeclaration
/**
* @constructor
* @param {((cssText: string) => void) | null} [onChangeCallback]
* The callback that is invoked whenever a property changes.
*/
function CSSStyleDeclaration(onChangeCallback = null) {
if (new.target === undefined) {
throw new TypeError("Class constructor CSSStyleDeclaration cannot be invoked without 'new'")
}
if (onChangeCallback !== null && typeof onChangeCallback !== 'function') {
throw new TypeError('Failed to construct CSSStyleDeclaration: parameter 1 is not a function')
}
return webidlWrapper.create(sharedGlobalObject, undefined, { onChangeCallback })
}
sharedGlobalObject.CSSStyleDeclaration = CSSStyleDeclaration
Object.defineProperty(CSSStyleDeclaration, 'prototype', {
value: origCSSStyleDeclaration.prototype,
writable: false,
})
CSSStyleDeclaration.prototype.constructor = CSSStyleDeclaration
Object.setPrototypeOf(CSSStyleDeclaration, Object.getPrototypeOf(origCSSStyleDeclaration))
module.exports = CSSStyleDeclaration