]>
git.proxmox.com Git - mirror_novnc.git/blob - core/util/polyfill.js
2 * noVNC: HTML5 VNC client
3 * Copyright 2017 Pierre Ossman for noVNC
4 * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
7 /* Polyfills to provide new APIs in old browsers */
9 /* Object.assign() (taken from MDN) */
10 if (typeof Object
.assign
!= 'function') {
11 // Must be writable: true, enumerable: false, configurable: true
12 Object
.defineProperty(Object
, "assign", {
13 value
: function assign(target
, varArgs
) { // .length of function is 2
15 if (target
== null) { // TypeError if undefined or null
16 throw new TypeError('Cannot convert undefined or null to object');
19 var to
= Object(target
);
21 for (var index
= 1; index
< arguments
.length
; index
++) {
22 var nextSource
= arguments
[index
];
24 if (nextSource
!= null) { // Skip over if undefined or null
25 for (var nextKey
in nextSource
) {
26 // Avoid bugs when hasOwnProperty is shadowed
27 if (Object
.prototype.hasOwnProperty
.call(nextSource
, nextKey
)) {
28 to
[nextKey
] = nextSource
[nextKey
];
40 /* CustomEvent constructor (taken from MDN) */
42 function CustomEvent ( event
, params
) {
43 params
= params
|| { bubbles
: false, cancelable
: false, detail
: undefined };
44 var evt
= document
.createEvent( 'CustomEvent' );
45 evt
.initCustomEvent( event
, params
.bubbles
, params
.cancelable
, params
.detail
);
49 CustomEvent
.prototype = window
.Event
.prototype;
51 if (typeof window
.CustomEvent
!== "function") {
52 window
.CustomEvent
= CustomEvent
;