Reactix.js 857 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
'use strict';

function addRootElement(rootElem) {
  document.body.insertBefore(
    rootElem,
    document.body.lastElementChild.nextElementSibling
  );
}

10 11 12 13
function getSelection(_u) {
  return window.getSelection();
}

14 15 16 17
function stringify(j, indent) {
  return JSON.stringify(j, null, indent);
}

18 19 20 21
function postMessage(obj, msg, src) {
    obj.contentWindow.postMessage(msg, src);
}

22 23 24 25
function setCookie(c) {
  document.cookie = c;
}

26 27 28 29
function domRectFromRect(obj) {
  return DOMRectReadOnly.fromRect(obj)
}

30
exports._addRootElement = addRootElement;
31
exports._getSelection = getSelection;
32
exports._stringify = stringify;
33
exports._postMessage = postMessage;
34
exports._setCookie = setCookie;
35
exports._domRectFromRect = domRectFromRect;
36 37 38 39 40

exports._keyCode = function(e) {
  // https://www.w3schools.com/jsref/event_key_keycode.asp
  return e.which || e.keyCode;
}