blob: 91c481feb9c27ca94bd950285a48ed3cde29085f (
plain)
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
|
// Force releasing decoder to avoid timeout in waiting for decoding resource.
function removeNodeAndSource(n) {
n.remove();
// reset |srcObject| first since it takes precedence over |src|.
n.srcObject = null;
n.removeAttribute("src");
n.load();
while (n.firstChild) {
n.firstChild.remove();
}
}
function once(target, name, cb) {
var p = new Promise(function (resolve, reject) {
target.addEventListener(
name,
function () {
resolve();
},
{ once: true }
);
});
if (cb) {
p.then(cb);
}
return p;
}
|