diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2019-02-06 16:56:55 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2019-02-06 16:56:55 +0100 |
commit | f3f392caec43b4095bc1d84b315ed7972c13c144 (patch) | |
tree | 5c4ba8b5d38f1ae33de71507c5634a15a0b35bfe /webclients/novnc/core/util/polyfill.js | |
parent | 8c081c8888bccbf5adfe0fc4ec518e2cbfba9871 (diff) | |
parent | 0a70095271d845d16a3ed17354841b01f33963ad (diff) | |
download | libtdevnc-f3f392caec43b4095bc1d84b315ed7972c13c144.tar.gz libtdevnc-f3f392caec43b4095bc1d84b315ed7972c13c144.zip |
Merge tag 'LibVNCServer-0.9.12'
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'webclients/novnc/core/util/polyfill.js')
-rw-r--r-- | webclients/novnc/core/util/polyfill.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/webclients/novnc/core/util/polyfill.js b/webclients/novnc/core/util/polyfill.js new file mode 100644 index 0000000..8c600e6 --- /dev/null +++ b/webclients/novnc/core/util/polyfill.js @@ -0,0 +1,54 @@ +/* + * noVNC: HTML5 VNC client + * Copyright 2017 Pierre Ossman for noVNC + * Licensed under MPL 2.0 or any later version (see LICENSE.txt) + */ + +/* Polyfills to provide new APIs in old browsers */ + +/* Object.assign() (taken from MDN) */ +if (typeof Object.assign != 'function') { + // Must be writable: true, enumerable: false, configurable: true + Object.defineProperty(Object, "assign", { + value: function assign(target, varArgs) { // .length of function is 2 + 'use strict'; + if (target == null) { // TypeError if undefined or null + throw new TypeError('Cannot convert undefined or null to object'); + } + + var to = Object(target); + + for (var index = 1; index < arguments.length; index++) { + var nextSource = arguments[index]; + + if (nextSource != null) { // Skip over if undefined or null + for (var nextKey in nextSource) { + // Avoid bugs when hasOwnProperty is shadowed + if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { + to[nextKey] = nextSource[nextKey]; + } + } + } + } + return to; + }, + writable: true, + configurable: true + }); +} + +/* CustomEvent constructor (taken from MDN) */ +(function () { + function CustomEvent ( event, params ) { + params = params || { bubbles: false, cancelable: false, detail: undefined }; + var evt = document.createEvent( 'CustomEvent' ); + evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); + return evt; + } + + CustomEvent.prototype = window.Event.prototype; + + if (typeof window.CustomEvent !== "function") { + window.CustomEvent = CustomEvent; + } +})(); |