Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

govuk-frontend

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

govuk-frontend - npm Package Compare versions

Comparing version 3.8.1 to 3.9.0

govuk/components/accordion/fixtures.json

2

govuk/components/accordion/README.md

@@ -9,3 +9,3 @@ # Accordion

Find out when to use the details component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/accordion).
Find out when to use the accordion component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/accordion).

@@ -12,0 +12,0 @@ ## Component options

@@ -59,2 +59,8 @@ [

{
"name": "html",
"type": "string",
"required": false,
"description": "HTML to use/render within the fieldset element."
},
{
"name": "caller",

@@ -61,0 +67,0 @@ "type": "nunjucks-block",

@@ -9,247 +9,2 @@ (function (global, factory) {

// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
var detect = (
// In IE8, defineProperty could only act on DOM elements, so full support
// for the feature requires the ability to set a property on an arbitrary object
'defineProperty' in Object && (function() {
try {
var a = {};
Object.defineProperty(a, 'test', {value:42});
return true;
} catch(e) {
return false
}
}())
);
if (detect) return
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
(function (nativeDefineProperty) {
var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
Object.defineProperty = function defineProperty(object, property, descriptor) {
// Where native support exists, assume it
if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
return nativeDefineProperty(object, property, descriptor);
}
if (object === null || !(object instanceof Object || typeof object === 'object')) {
throw new TypeError('Object.defineProperty called on non-object');
}
if (!(descriptor instanceof Object)) {
throw new TypeError('Property description must be an object');
}
var propertyString = String(property);
var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
var getterType = 'get' in descriptor && typeof descriptor.get;
var setterType = 'set' in descriptor && typeof descriptor.set;
// handle descriptor.get
if (getterType) {
if (getterType !== 'function') {
throw new TypeError('Getter must be a function');
}
if (!supportsAccessors) {
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
}
if (hasValueOrWritable) {
throw new TypeError(ERR_VALUE_ACCESSORS);
}
Object.__defineGetter__.call(object, propertyString, descriptor.get);
} else {
object[propertyString] = descriptor.value;
}
// handle descriptor.set
if (setterType) {
if (setterType !== 'function') {
throw new TypeError('Setter must be a function');
}
if (!supportsAccessors) {
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
}
if (hasValueOrWritable) {
throw new TypeError(ERR_VALUE_ACCESSORS);
}
Object.__defineSetter__.call(object, propertyString, descriptor.set);
}
// OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
if ('value' in descriptor) {
object[propertyString] = descriptor.value;
}
return object;
};
}(Object.defineProperty));
})
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
(function(undefined) {
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
var detect = 'bind' in Function.prototype;
if (detect) return
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
Object.defineProperty(Function.prototype, 'bind', {
value: function bind(that) { // .length is 1
// add necessary es5-shim utilities
var $Array = Array;
var $Object = Object;
var ObjectPrototype = $Object.prototype;
var ArrayPrototype = $Array.prototype;
var Empty = function Empty() {};
var to_string = ObjectPrototype.toString;
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
var array_slice = ArrayPrototype.slice;
var array_concat = ArrayPrototype.concat;
var array_push = ArrayPrototype.push;
var max = Math.max;
// /add necessary es5-shim utilities
// 1. Let Target be the this value.
var target = this;
// 2. If IsCallable(Target) is false, throw a TypeError exception.
if (!isCallable(target)) {
throw new TypeError('Function.prototype.bind called on incompatible ' + target);
}
// 3. Let A be a new (possibly empty) internal list of all of the
// argument values provided after thisArg (arg1, arg2 etc), in order.
// XXX slicedArgs will stand in for "A" if used
var args = array_slice.call(arguments, 1); // for normal call
// 4. Let F be a new native ECMAScript object.
// 11. Set the [[Prototype]] internal property of F to the standard
// built-in Function prototype object as specified in 15.3.3.1.
// 12. Set the [[Call]] internal property of F as described in
// 15.3.4.5.1.
// 13. Set the [[Construct]] internal property of F as described in
// 15.3.4.5.2.
// 14. Set the [[HasInstance]] internal property of F as described in
// 15.3.4.5.3.
var bound;
var binder = function () {
if (this instanceof bound) {
// 15.3.4.5.2 [[Construct]]
// When the [[Construct]] internal method of a function object,
// F that was created using the bind function is called with a
// list of arguments ExtraArgs, the following steps are taken:
// 1. Let target be the value of F's [[TargetFunction]]
// internal property.
// 2. If target has no [[Construct]] internal method, a
// TypeError exception is thrown.
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
// property.
// 4. Let args be a new list containing the same values as the
// list boundArgs in the same order followed by the same
// values as the list ExtraArgs in the same order.
// 5. Return the result of calling the [[Construct]] internal
// method of target providing args as the arguments.
var result = target.apply(
this,
array_concat.call(args, array_slice.call(arguments))
);
if ($Object(result) === result) {
return result;
}
return this;
} else {
// 15.3.4.5.1 [[Call]]
// When the [[Call]] internal method of a function object, F,
// which was created using the bind function is called with a
// this value and a list of arguments ExtraArgs, the following
// steps are taken:
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
// property.
// 2. Let boundThis be the value of F's [[BoundThis]] internal
// property.
// 3. Let target be the value of F's [[TargetFunction]] internal
// property.
// 4. Let args be a new list containing the same values as the
// list boundArgs in the same order followed by the same
// values as the list ExtraArgs in the same order.
// 5. Return the result of calling the [[Call]] internal method
// of target providing boundThis as the this value and
// providing args as the arguments.
// equiv: target.call(this, ...boundArgs, ...args)
return target.apply(
that,
array_concat.call(args, array_slice.call(arguments))
);
}
};
// 15. If the [[Class]] internal property of Target is "Function", then
// a. Let L be the length property of Target minus the length of A.
// b. Set the length own property of F to either 0 or L, whichever is
// larger.
// 16. Else set the length own property of F to 0.
var boundLength = max(0, target.length - args.length);
// 17. Set the attributes of the length own property of F to the values
// specified in 15.3.5.1.
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
array_push.call(boundArgs, '$' + i);
}
// XXX Build a dynamic function with desired amount of arguments is the only
// way to set the length property of a function.
// In environments where Content Security Policies enabled (Chrome extensions,
// for ex.) all use of eval or Function costructor throws an exception.
// However in all of these environments Function.prototype.bind exists
// and so this code will never be executed.
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
if (target.prototype) {
Empty.prototype = target.prototype;
bound.prototype = new Empty();
// Clean up dangling references.
Empty.prototype = null;
}
// TODO
// 18. Set the [[Extensible]] internal property of F to true.
// TODO
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
// 20. Call the [[DefineOwnProperty]] internal method of F with
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
// false.
// 21. Call the [[DefineOwnProperty]] internal method of F with
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
// and false.
// TODO
// NOTE Function objects created using Function.prototype.bind do not
// have a prototype property or the [[Code]], [[FormalParameters]], and
// [[Scope]] internal properties.
// XXX can't delete prototype in pure-js.
// 22. Return F.
return bound;
}
});
})
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
(function(undefined) {
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js

@@ -416,2 +171,89 @@ var detect = ('Window' in this);

// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
var detect = (
// In IE8, defineProperty could only act on DOM elements, so full support
// for the feature requires the ability to set a property on an arbitrary object
'defineProperty' in Object && (function() {
try {
var a = {};
Object.defineProperty(a, 'test', {value:42});
return true;
} catch(e) {
return false
}
}())
);
if (detect) return
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
(function (nativeDefineProperty) {
var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
Object.defineProperty = function defineProperty(object, property, descriptor) {
// Where native support exists, assume it
if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
return nativeDefineProperty(object, property, descriptor);
}
if (object === null || !(object instanceof Object || typeof object === 'object')) {
throw new TypeError('Object.defineProperty called on non-object');
}
if (!(descriptor instanceof Object)) {
throw new TypeError('Property description must be an object');
}
var propertyString = String(property);
var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
var getterType = 'get' in descriptor && typeof descriptor.get;
var setterType = 'set' in descriptor && typeof descriptor.set;
// handle descriptor.get
if (getterType) {
if (getterType !== 'function') {
throw new TypeError('Getter must be a function');
}
if (!supportsAccessors) {
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
}
if (hasValueOrWritable) {
throw new TypeError(ERR_VALUE_ACCESSORS);
}
Object.__defineGetter__.call(object, propertyString, descriptor.get);
} else {
object[propertyString] = descriptor.value;
}
// handle descriptor.set
if (setterType) {
if (setterType !== 'function') {
throw new TypeError('Setter must be a function');
}
if (!supportsAccessors) {
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
}
if (hasValueOrWritable) {
throw new TypeError(ERR_VALUE_ACCESSORS);
}
Object.__defineSetter__.call(object, propertyString, descriptor.set);
}
// OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
if ('value' in descriptor) {
object[propertyString] = descriptor.value;
}
return object;
};
}(Object.defineProperty));
})
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
(function(undefined) {
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js

@@ -664,53 +506,561 @@ var detect = (

(function(undefined) {
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
var detect = (
'DOMTokenList' in this && (function (x) {
return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
})(document.createElement('x'))
);
if (detect) return
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
(function (global) {
var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
if (
!nativeImpl ||
(
!!document.createElementNS &&
!!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
!(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
)
) {
global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
var dpSupport = true;
var defineGetter = function (object, name, fn, configurable) {
if (Object.defineProperty)
Object.defineProperty(object, name, {
configurable: false === dpSupport ? true : !!configurable,
get: fn
});
else object.__defineGetter__(name, fn);
};
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
try {
defineGetter({}, "support");
}
catch (e) {
dpSupport = false;
}
var _DOMTokenList = function (el, prop) {
var that = this;
var tokens = [];
var tokenMap = {};
var length = 0;
var maxLength = 0;
var addIndexGetter = function (i) {
defineGetter(that, i, function () {
preop();
return tokens[i];
}, false);
};
var reindex = function () {
/** Define getter functions for array-like access to the tokenList's contents. */
if (length >= maxLength)
for (; maxLength < length; ++maxLength) {
addIndexGetter(maxLength);
}
};
/** Helper function called at the start of each class method. Internal use only. */
var preop = function () {
var error;
var i;
var args = arguments;
var rSpace = /\s+/;
/** Validate the token/s passed to an instance method, if any. */
if (args.length)
for (i = 0; i < args.length; ++i)
if (rSpace.test(args[i])) {
error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
error.code = 5;
error.name = "InvalidCharacterError";
throw error;
}
/** Split the new value apart by whitespace*/
if (typeof el[prop] === "object") {
tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
} else {
tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
}
/** Avoid treating blank strings as single-item token lists */
if ("" === tokens[0]) tokens = [];
/** Repopulate the internal token lists */
tokenMap = {};
for (i = 0; i < tokens.length; ++i)
tokenMap[tokens[i]] = true;
length = tokens.length;
reindex();
};
/** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
preop();
/** Return the number of tokens in the underlying string. Read-only. */
defineGetter(that, "length", function () {
preop();
return length;
});
/** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
that.toLocaleString =
that.toString = function () {
preop();
return tokens.join(" ");
};
that.item = function (idx) {
preop();
return tokens[idx];
};
that.contains = function (token) {
preop();
return !!tokenMap[token];
};
that.add = function () {
preop.apply(that, args = arguments);
for (var args, token, i = 0, l = args.length; i < l; ++i) {
token = args[i];
if (!tokenMap[token]) {
tokens.push(token);
tokenMap[token] = true;
}
}
/** Update the targeted attribute of the attached element if the token list's changed. */
if (length !== tokens.length) {
length = tokens.length >>> 0;
if (typeof el[prop] === "object") {
el[prop].baseVal = tokens.join(" ");
} else {
el[prop] = tokens.join(" ");
}
reindex();
}
};
that.remove = function () {
preop.apply(that, args = arguments);
/** Build a hash of token names to compare against when recollecting our token list. */
for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
ignore[args[i]] = true;
delete tokenMap[args[i]];
}
/** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
for (i = 0; i < tokens.length; ++i)
if (!ignore[tokens[i]]) t.push(tokens[i]);
tokens = t;
length = t.length >>> 0;
/** Update the targeted attribute of the attached element. */
if (typeof el[prop] === "object") {
el[prop].baseVal = tokens.join(" ");
} else {
el[prop] = tokens.join(" ");
}
reindex();
};
that.toggle = function (token, force) {
preop.apply(that, [token]);
/** Token state's being forced. */
if (undefined !== force) {
if (force) {
that.add(token);
return true;
} else {
that.remove(token);
return false;
}
}
/** Token already exists in tokenList. Remove it, and return FALSE. */
if (tokenMap[token]) {
that.remove(token);
return false;
}
/** Otherwise, add the token and return TRUE. */
that.add(token);
return true;
};
return that;
};
return _DOMTokenList;
}());
}
// Add second argument to native DOMTokenList.toggle() if necessary
(function () {
var e = document.createElement('span');
if (!('classList' in e)) return;
e.classList.toggle('x', false);
if (!e.classList.contains('x')) return;
e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
var force = arguments[1];
if (force === undefined) {
var add = !this.contains(token);
this[add ? 'add' : 'remove'](token);
return add;
}
force = !!force;
this[force ? 'add' : 'remove'](token);
return force;
};
}());
// Add multiple arguments to native DOMTokenList.add() if necessary
(function () {
var e = document.createElement('span');
if (!('classList' in e)) return;
e.classList.add('a', 'b');
if (e.classList.contains('b')) return;
var native = e.classList.constructor.prototype.add;
e.classList.constructor.prototype.add = function () {
var args = arguments;
var l = arguments.length;
for (var i = 0; i < l; i++) {
native.call(this, args[i]);
}
};
}());
// Add multiple arguments to native DOMTokenList.remove() if necessary
(function () {
var e = document.createElement('span');
if (!('classList' in e)) return;
e.classList.add('a');
e.classList.add('b');
e.classList.remove('a', 'b');
if (!e.classList.contains('b')) return;
var native = e.classList.constructor.prototype.remove;
e.classList.constructor.prototype.remove = function () {
var args = arguments;
var l = arguments.length;
for (var i = 0; i < l; i++) {
native.call(this, args[i]);
}
};
}());
}(this));
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
(function(undefined) {
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
var detect = (
'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
var e = document.createElement('span');
e.classList.add('a', 'b');
return e.classList.contains('b');
}())
);
if (detect) return
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
(function (global) {
var dpSupport = true;
var defineGetter = function (object, name, fn, configurable) {
if (Object.defineProperty)
Object.defineProperty(object, name, {
configurable: false === dpSupport ? true : !!configurable,
get: fn
});
else object.__defineGetter__(name, fn);
};
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
try {
defineGetter({}, "support");
}
catch (e) {
dpSupport = false;
}
/** Polyfills a property with a DOMTokenList */
var addProp = function (o, name, attr) {
defineGetter(o.prototype, name, function () {
var tokenList;
var THIS = this,
/** Prevent this from firing twice for some reason. What the hell, IE. */
gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
if(THIS[gibberishProperty]) return tokenList;
THIS[gibberishProperty] = true;
/**
* IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
*
* What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
* that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
* element instead, this would conflict with element types which use indexed properties (such as forms and
* select lists).
*/
if (false === dpSupport) {
var visage;
var mirror = addProp.mirror || document.createElement("div");
var reflections = mirror.childNodes;
var l = reflections.length;
for (var i = 0; i < l; ++i)
if (reflections[i]._R === THIS) {
visage = reflections[i];
break;
}
/** Couldn't find an element's reflection inside the mirror. Materialise one. */
visage || (visage = mirror.appendChild(document.createElement("div")));
tokenList = DOMTokenList.call(visage, THIS, attr);
} else tokenList = new DOMTokenList(THIS, attr);
defineGetter(THIS, name, function () {
return tokenList;
});
delete THIS[gibberishProperty];
return tokenList;
}, true);
};
addProp(global.Element, "classList", "className");
addProp(global.HTMLElement, "classList", "className");
addProp(global.HTMLLinkElement, "relList", "rel");
addProp(global.HTMLAnchorElement, "relList", "rel");
addProp(global.HTMLAreaElement, "relList", "rel");
}(this));
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
(function(undefined) {
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
var detect = 'bind' in Function.prototype;
if (detect) return
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
Object.defineProperty(Function.prototype, 'bind', {
value: function bind(that) { // .length is 1
// add necessary es5-shim utilities
var $Array = Array;
var $Object = Object;
var ObjectPrototype = $Object.prototype;
var ArrayPrototype = $Array.prototype;
var Empty = function Empty() {};
var to_string = ObjectPrototype.toString;
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
var array_slice = ArrayPrototype.slice;
var array_concat = ArrayPrototype.concat;
var array_push = ArrayPrototype.push;
var max = Math.max;
// /add necessary es5-shim utilities
// 1. Let Target be the this value.
var target = this;
// 2. If IsCallable(Target) is false, throw a TypeError exception.
if (!isCallable(target)) {
throw new TypeError('Function.prototype.bind called on incompatible ' + target);
}
// 3. Let A be a new (possibly empty) internal list of all of the
// argument values provided after thisArg (arg1, arg2 etc), in order.
// XXX slicedArgs will stand in for "A" if used
var args = array_slice.call(arguments, 1); // for normal call
// 4. Let F be a new native ECMAScript object.
// 11. Set the [[Prototype]] internal property of F to the standard
// built-in Function prototype object as specified in 15.3.3.1.
// 12. Set the [[Call]] internal property of F as described in
// 15.3.4.5.1.
// 13. Set the [[Construct]] internal property of F as described in
// 15.3.4.5.2.
// 14. Set the [[HasInstance]] internal property of F as described in
// 15.3.4.5.3.
var bound;
var binder = function () {
if (this instanceof bound) {
// 15.3.4.5.2 [[Construct]]
// When the [[Construct]] internal method of a function object,
// F that was created using the bind function is called with a
// list of arguments ExtraArgs, the following steps are taken:
// 1. Let target be the value of F's [[TargetFunction]]
// internal property.
// 2. If target has no [[Construct]] internal method, a
// TypeError exception is thrown.
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
// property.
// 4. Let args be a new list containing the same values as the
// list boundArgs in the same order followed by the same
// values as the list ExtraArgs in the same order.
// 5. Return the result of calling the [[Construct]] internal
// method of target providing args as the arguments.
var result = target.apply(
this,
array_concat.call(args, array_slice.call(arguments))
);
if ($Object(result) === result) {
return result;
}
return this;
} else {
// 15.3.4.5.1 [[Call]]
// When the [[Call]] internal method of a function object, F,
// which was created using the bind function is called with a
// this value and a list of arguments ExtraArgs, the following
// steps are taken:
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
// property.
// 2. Let boundThis be the value of F's [[BoundThis]] internal
// property.
// 3. Let target be the value of F's [[TargetFunction]] internal
// property.
// 4. Let args be a new list containing the same values as the
// list boundArgs in the same order followed by the same
// values as the list ExtraArgs in the same order.
// 5. Return the result of calling the [[Call]] internal method
// of target providing boundThis as the this value and
// providing args as the arguments.
// equiv: target.call(this, ...boundArgs, ...args)
return target.apply(
that,
array_concat.call(args, array_slice.call(arguments))
);
}
};
// 15. If the [[Class]] internal property of Target is "Function", then
// a. Let L be the length property of Target minus the length of A.
// b. Set the length own property of F to either 0 or L, whichever is
// larger.
// 16. Else set the length own property of F to 0.
var boundLength = max(0, target.length - args.length);
// 17. Set the attributes of the length own property of F to the values
// specified in 15.3.5.1.
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
array_push.call(boundArgs, '$' + i);
}
// XXX Build a dynamic function with desired amount of arguments is the only
// way to set the length property of a function.
// In environments where Content Security Policies enabled (Chrome extensions,
// for ex.) all use of eval or Function costructor throws an exception.
// However in all of these environments Function.prototype.bind exists
// and so this code will never be executed.
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
if (target.prototype) {
Empty.prototype = target.prototype;
bound.prototype = new Empty();
// Clean up dangling references.
Empty.prototype = null;
}
// TODO
// 18. Set the [[Extensible]] internal property of F to true.
// TODO
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
// 20. Call the [[DefineOwnProperty]] internal method of F with
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
// false.
// 21. Call the [[DefineOwnProperty]] internal method of F with
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
// and false.
// TODO
// NOTE Function objects created using Function.prototype.bind do not
// have a prototype property or the [[Code]], [[FormalParameters]], and
// [[Scope]] internal properties.
// XXX can't delete prototype in pure-js.
// 22. Return F.
return bound;
}
});
})
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
function Header ($module) {
this.$module = $module;
this.$menuButton = $module && $module.querySelector('.govuk-js-header-toggle');
this.$menu = this.$menuButton && $module.querySelector(
'#' + this.$menuButton.getAttribute('aria-controls')
);
}
/**
* Initialise header
*
* Check for the presence of the header, menu and menu button – if any are
* missing then there's nothing to do so return early.
*/
Header.prototype.init = function () {
// Check for module
var $module = this.$module;
if (!$module) {
if (!this.$module || !this.$menuButton || !this.$menu) {
return
}
// Check for button
var $toggleButton = $module.querySelector('.govuk-js-header-toggle');
if (!$toggleButton) {
return
}
// Handle $toggleButton click events
$toggleButton.addEventListener('click', this.handleClick.bind(this));
this.syncState(this.$menu.classList.contains('govuk-header__navigation--open'));
this.$menuButton.addEventListener('click', this.handleMenuButtonClick.bind(this));
};
/**
* Toggle class
* @param {object} node element
* @param {string} className to toggle
*/
Header.prototype.toggleClass = function (node, className) {
if (node.className.indexOf(className) > 0) {
node.className = node.className.replace(' ' + className, '');
} else {
node.className += ' ' + className;
}
* Sync menu state
*
* Sync the menu button class and the accessible state of the menu and the menu
* button with the visible state of the menu
*
* @param {boolean} isVisible Whether the menu is currently visible
*/
Header.prototype.syncState = function (isVisible) {
this.$menuButton.classList.toggle('govuk-header__menu-button--open', isVisible);
this.$menuButton.setAttribute('aria-expanded', isVisible);
this.$menu.setAttribute('aria-hidden', !isVisible);
};
/**
* An event handler for click event on $toggleButton
* @param {object} event event
*/
Header.prototype.handleClick = function (event) {
var $module = this.$module;
var $toggleButton = event.target || event.srcElement;
var $target = $module.querySelector('#' + $toggleButton.getAttribute('aria-controls'));
// If a button with aria-controls, handle click
if ($toggleButton && $target) {
this.toggleClass($target, 'govuk-header__navigation--open');
this.toggleClass($toggleButton, 'govuk-header__menu-button--open');
$toggleButton.setAttribute('aria-expanded', $toggleButton.getAttribute('aria-expanded') !== 'true');
$target.setAttribute('aria-hidden', $target.getAttribute('aria-hidden') === 'false');
}
* Handle menu button click
*
* When the menu button is clicked, change the visibility of the menu and then
* sync the accessibility state and menu button state
*/
Header.prototype.handleMenuButtonClick = function () {
var isVisible = this.$menu.classList.toggle('govuk-header__navigation--open');
this.syncState(isVisible);
};

@@ -717,0 +1067,0 @@

@@ -54,3 +54,3 @@ [

"required": false,
"description": "Url of the navigation item anchor. Both `href` and `text` attributes for navigation items need to be provided to create an item."
"description": "Url of the navigation item anchor."
},

@@ -78,2 +78,14 @@ {

{
"name": "navigationLabel",
"type": "string",
"required": false,
"description": "Text for the `aria-label` attribute of the navigation. Defaults to \"Navigation menu\"."
},
{
"name": "menuButtonLabel",
"type": "string",
"required": false,
"description": "Text for the `aria-label` attribute of the button that toggles the navigation. Defaults to \"Show or hide navigation menu\"."
},
{
"name": "containerClasses",

@@ -80,0 +92,0 @@ "type": "string",

@@ -17,3 +17,3 @@ [

"type": "string",
"required": true,
"required": false,
"description": "Optional id attribute to add to the hint span tag."

@@ -20,0 +20,0 @@ },

@@ -60,2 +60,66 @@ [

{
"name": "prefix",
"type": "object",
"required": false,
"description": "Options for the prefix element.",
"params": [
{
"name": "text",
"type": "string",
"required": true,
"description": "Required. If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` argument will be ignored."
},
{
"name": "html",
"type": "string",
"required": true,
"description": "Required. If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` argument will be ignored."
},
{
"name": "classes",
"type": "string",
"required": false,
"description": "Classes to add to the prefix."
},
{
"name": "attributes",
"type": "object",
"required": false,
"description": "HTML attributes (for example data attributes) to add to the prefix element."
}
]
},
{
"name": "suffix",
"type": "object",
"required": false,
"description": "Options for the suffix element.",
"params": [
{
"name": "text",
"type": "string",
"required": true,
"description": "Required. If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` argument will be ignored."
},
{
"name": "html",
"type": "string",
"required": true,
"description": "Required. If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` argument will be ignored."
},
{
"name": "classes",
"type": "string",
"required": false,
"description": "Classes to add to the suffix element."
},
{
"name": "attributes",
"type": "object",
"required": false,
"description": "HTML attributes (for example data attributes) to add to the suffix element."
}
]
},
{
"name": "formGroup",

@@ -62,0 +126,0 @@ "type": "object",

@@ -41,3 +41,3 @@ [

"required": false,
"description": "String to prefix id for each checkbox item if no id is specified on each item. If `idPrefix` is not passed, fallback to using the name attribute instead."
"description": "String to prefix id for each radio item if no id is specified on each item. If `idPrefix` is not passed, fallback to using the name attribute instead."
},

@@ -91,3 +91,3 @@ {

"required": false,
"description": "Provide hint to each checkbox item.",
"description": "Provide hint to each radio item.",
"isComponent": true

@@ -94,0 +94,0 @@ },

@@ -9,3 +9,3 @@ # Summary list

Find out when to use the details component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/summary-list).
Find out when to use the summary list component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/summary-list).

@@ -12,0 +12,0 @@ ## Component options

{
"name": "govuk-frontend",
"description": "GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.",
"version": "3.8.1",
"version": "3.9.0",
"main": "govuk/all.js",

@@ -6,0 +6,0 @@ "sass": "govuk/all.scss",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc