Revert "Merge pull request #3238 from alphagov/cookies-update"

This reverts commit eec4bec761, reversing
changes made to 64480e2fff.
This commit is contained in:
Leo Hemsted
2020-01-15 14:40:48 +00:00
parent 04b9fa8927
commit 66db735e09
36 changed files with 116 additions and 1610 deletions

View File

@@ -1,7 +1,6 @@
const globals = require('./helpers/globals.js');
const events = require('./helpers/events.js');
const domInterfaces = require('./helpers/dom_interfaces.js');
const cookies = require('./helpers/cookies.js');
const html = require('./helpers/html.js');
const elements = require('./helpers/elements.js');
const rendering = require('./helpers/rendering.js');
@@ -15,8 +14,6 @@ exports.moveSelectionToRadio = events.moveSelectionToRadio;
exports.activateRadioWithSpace = events.activateRadioWithSpace;
exports.RangeMock = domInterfaces.RangeMock;
exports.SelectionMock = domInterfaces.SelectionMock;
exports.deleteCookie = cookies.deleteCookie;
exports.setCookie = cookies.setCookie;
exports.getRadioGroup = html.getRadioGroup;
exports.getRadios = html.getRadios;
exports.templatesAndFoldersCheckboxes = html.templatesAndFoldersCheckboxes;

View File

@@ -1,22 +0,0 @@
// Helper for deleting a cookie
function deleteCookie (cookieName) {
document.cookie = cookieName + '=; path=/; expires=' + (new Date());
};
function setCookie (name, value, options) {
if (typeof options === 'undefined') {
options = {};
}
var cookieString = name + '=' + value + '; path=/;domain=' + window.location.hostname;
if (options.days) {
var date = new Date();
date.setTime(date.getTime() + (options.days * 24 * 60 * 60 * 1000));
cookieString = cookieString + '; expires=' + date.toGMTString();
}
document.cookie = cookieString;
};
exports.deleteCookie = deleteCookie;
exports.setCookie = setCookie;

View File

@@ -1,53 +0,0 @@
// Polyfills for any parts of the DOM API available in browsers but not JSDOM
// From: https://gist.github.com/eligrey/1276030
HTMLElement.prototype.insertAdjacentHTML = function(position, html) {
"use strict";
var
ref = this
, container = ref.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml", "_")
, ref_parent = ref.parentNode
, node, first_child, next_sibling
;
container.innerHTML = html;
switch (position.toLowerCase()) {
case "beforebegin":
while ((node = container.firstChild)) {
ref_parent.insertBefore(node, ref);
}
break;
case "afterbegin":
first_child = ref.firstChild;
while ((node = container.lastChild)) {
first_child = ref.insertBefore(node, first_child);
}
break;
case "beforeend":
while ((node = container.firstChild)) {
ref.appendChild(node);
}
break;
case "afterend":
next_sibling = ref.nextSibling;
while ((node = container.lastChild)) {
next_sibling = ref_parent.insertBefore(node, next_sibling);
}
break;
}
};
// from: https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentText#Polyfill
if (!Element.prototype.insertAdjacentText) {
Element.prototype.insertAdjacentText = function(type, txt){
this.insertAdjacentHTML(
type,
(txt+'') // convert to string
.replace(/&/g, '&') // embed ampersand symbols
.replace(/</g, '&lt;') // embed less-than symbols
)
}
}

View File

@@ -1,6 +1,3 @@
// Polyfill holes in JSDOM
require('./polyfills.js');
// set up jQuery
window.jQuery = require('jquery');
$ = window.jQuery;