[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | const { webidl } = require('../fetch/webidl')
|
---|
| 4 |
|
---|
| 5 | const kState = Symbol('ProgressEvent state')
|
---|
| 6 |
|
---|
| 7 | /**
|
---|
| 8 | * @see https://xhr.spec.whatwg.org/#progressevent
|
---|
| 9 | */
|
---|
| 10 | class ProgressEvent extends Event {
|
---|
| 11 | constructor (type, eventInitDict = {}) {
|
---|
| 12 | type = webidl.converters.DOMString(type)
|
---|
| 13 | eventInitDict = webidl.converters.ProgressEventInit(eventInitDict ?? {})
|
---|
| 14 |
|
---|
| 15 | super(type, eventInitDict)
|
---|
| 16 |
|
---|
| 17 | this[kState] = {
|
---|
| 18 | lengthComputable: eventInitDict.lengthComputable,
|
---|
| 19 | loaded: eventInitDict.loaded,
|
---|
| 20 | total: eventInitDict.total
|
---|
| 21 | }
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | get lengthComputable () {
|
---|
| 25 | webidl.brandCheck(this, ProgressEvent)
|
---|
| 26 |
|
---|
| 27 | return this[kState].lengthComputable
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | get loaded () {
|
---|
| 31 | webidl.brandCheck(this, ProgressEvent)
|
---|
| 32 |
|
---|
| 33 | return this[kState].loaded
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | get total () {
|
---|
| 37 | webidl.brandCheck(this, ProgressEvent)
|
---|
| 38 |
|
---|
| 39 | return this[kState].total
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | webidl.converters.ProgressEventInit = webidl.dictionaryConverter([
|
---|
| 44 | {
|
---|
| 45 | key: 'lengthComputable',
|
---|
| 46 | converter: webidl.converters.boolean,
|
---|
| 47 | defaultValue: false
|
---|
| 48 | },
|
---|
| 49 | {
|
---|
| 50 | key: 'loaded',
|
---|
| 51 | converter: webidl.converters['unsigned long long'],
|
---|
| 52 | defaultValue: 0
|
---|
| 53 | },
|
---|
| 54 | {
|
---|
| 55 | key: 'total',
|
---|
| 56 | converter: webidl.converters['unsigned long long'],
|
---|
| 57 | defaultValue: 0
|
---|
| 58 | },
|
---|
| 59 | {
|
---|
| 60 | key: 'bubbles',
|
---|
| 61 | converter: webidl.converters.boolean,
|
---|
| 62 | defaultValue: false
|
---|
| 63 | },
|
---|
| 64 | {
|
---|
| 65 | key: 'cancelable',
|
---|
| 66 | converter: webidl.converters.boolean,
|
---|
| 67 | defaultValue: false
|
---|
| 68 | },
|
---|
| 69 | {
|
---|
| 70 | key: 'composed',
|
---|
| 71 | converter: webidl.converters.boolean,
|
---|
| 72 | defaultValue: false
|
---|
| 73 | }
|
---|
| 74 | ])
|
---|
| 75 |
|
---|
| 76 | module.exports = {
|
---|
| 77 | ProgressEvent
|
---|
| 78 | }
|
---|