Socket
Socket
Sign inDemoInstall

govuk-frontend

Package Overview
Dependencies
Maintainers
1
Versions
68
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.0.0 to 3.1.0

2

govuk/components/accordion/README.md

@@ -15,4 +15,2 @@ # Accordion

`id` option given to instances of the component must be **unique** across the domain of your service (as the expanded state of individual instances of the component persists across page loads using [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)).
See [options table](https://design-system.service.gov.uk/components/accordion/#options-example-default) for details.

6

govuk/components/button/macro-options.json

@@ -67,3 +67,9 @@ [

"description": "Prevent accidental double clicks on submit buttons from submitting forms multiple times"
},
{
"name": "isStartButton",
"type": "boolean",
"required": false,
"description": "Use for the main call to action on your service's start page."
}
]

@@ -693,5 +693,2 @@ (function (global, factory) {

// Create a flag to know if the browser supports navtive details
var NATIVE_DETAILS = typeof document.createElement('details').open === 'boolean';
function Details ($module) {

@@ -701,47 +698,20 @@ this.$module = $module;

/**
* Handle cross-modal click events
* @param {object} node element
* @param {function} callback function
*/
Details.prototype.handleInputs = function (node, callback) {
node.addEventListener('keypress', function (event) {
var target = event.target;
// When the key gets pressed - check if it is enter or space
if (event.keyCode === KEY_ENTER || event.keyCode === KEY_SPACE) {
if (target.nodeName.toLowerCase() === 'summary') {
// Prevent space from scrolling the page
// and enter from submitting a form
event.preventDefault();
// Click to let the click event do all the necessary action
if (target.click) {
target.click();
} else {
// except Safari 5.1 and under don't support .click() here
callback(event);
}
}
}
});
Details.prototype.init = function () {
if (!this.$module) {
return
}
// Prevent keyup to prevent clicking twice in Firefox when using space key
node.addEventListener('keyup', function (event) {
var target = event.target;
if (event.keyCode === KEY_SPACE) {
if (target.nodeName.toLowerCase() === 'summary') {
event.preventDefault();
}
}
});
// If there is native details support, we want to avoid running code to polyfill native behaviour.
var hasNativeDetails = typeof this.$module.open === 'boolean';
node.addEventListener('click', callback);
if (hasNativeDetails) {
return
}
this.polyfillDetails();
};
Details.prototype.init = function () {
Details.prototype.polyfillDetails = function () {
var $module = this.$module;
if (!$module) {
return
}
// Save shortcuts to the inner summary and content elements

@@ -776,5 +746,3 @@ var $summary = this.$summary = $module.getElementsByTagName('summary').item(0);

// See http://web.archive.org/web/20170120194036/http://www.saliences.com/browserBugs/tabIndex.html for more information.
if (!NATIVE_DETAILS) {
$summary.tabIndex = 0;
}
$summary.tabIndex = 0;

@@ -789,9 +757,7 @@ // Detect initial open state

$content.setAttribute('aria-hidden', 'true');
if (!NATIVE_DETAILS) {
$content.style.display = 'none';
}
$content.style.display = 'none';
}
// Bind an event to handle summary elements
this.handleInputs($summary, this.setAttributes.bind(this));
this.polyfillHandleInputs($summary, this.polyfillSetAttributes.bind(this));
};

@@ -803,3 +769,3 @@

*/
Details.prototype.setAttributes = function () {
Details.prototype.polyfillSetAttributes = function () {
var $module = this.$module;

@@ -815,12 +781,11 @@ var $summary = this.$summary;

if (!NATIVE_DETAILS) {
$content.style.display = (expanded ? 'none' : '');
$content.style.display = (expanded ? 'none' : '');
var hasOpenAttr = $module.getAttribute('open') !== null;
if (!hasOpenAttr) {
$module.setAttribute('open', 'open');
} else {
$module.removeAttribute('open');
}
var hasOpenAttr = $module.getAttribute('open') !== null;
if (!hasOpenAttr) {
$module.setAttribute('open', 'open');
} else {
$module.removeAttribute('open');
}
return true

@@ -830,9 +795,37 @@ };

/**
* Remove the click event from the node element
* Handle cross-modal click events
* @param {object} node element
* @param {function} callback function
*/
Details.prototype.destroy = function (node) {
node.removeEventListener('keypress');
node.removeEventListener('keyup');
node.removeEventListener('click');
Details.prototype.polyfillHandleInputs = function (node, callback) {
node.addEventListener('keypress', function (event) {
var target = event.target;
// When the key gets pressed - check if it is enter or space
if (event.keyCode === KEY_ENTER || event.keyCode === KEY_SPACE) {
if (target.nodeName.toLowerCase() === 'summary') {
// Prevent space from scrolling the page
// and enter from submitting a form
event.preventDefault();
// Click to let the click event do all the necessary action
if (target.click) {
target.click();
} else {
// except Safari 5.1 and under don't support .click() here
callback(event);
}
}
}
});
// Prevent keyup to prevent clicking twice in Firefox when using space key
node.addEventListener('keyup', function (event) {
var target = event.target;
if (event.keyCode === KEY_SPACE) {
if (target.nodeName.toLowerCase() === 'summary') {
event.preventDefault();
}
}
});
node.addEventListener('click', callback);
};

@@ -839,0 +832,0 @@

@@ -47,2 +47,8 @@ [

{
"name": "role",
"type": "string",
"required": false,
"description": "Optional ARIA role attribute."
},
{
"name": "attributes",

@@ -49,0 +55,0 @@ "type": "object",

@@ -21,2 +21,8 @@ [

{
"name": "inputmode",
"type": "string",
"require": false,
"description": "Optional value for [inputmode](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode)."
},
{
"name": "value",

@@ -23,0 +29,0 @@ "type": "string",

@@ -6,3 +6,3 @@ [

"required": true,
"description": "Array of row item objects",
"description": "Array of row item objects.",
"params": [

@@ -9,0 +9,0 @@ {

{
"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.0.0",
"version": "3.1.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

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