Socket
Socket
Sign inDemoInstall

govuk-frontend

Package Overview
Dependencies
0
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.12.0 to 3.13.0

64

govuk/components/checkboxes/checkboxes.js

@@ -1114,2 +1114,43 @@ (function (global, factory) {

/**
* Uncheck other checkboxes
*
* Find any other checkbox inputs with the same name value, and uncheck them.
* This is useful for when a “None of these" checkbox is checked.
*/
Checkboxes.prototype.unCheckAllInputsExcept = function ($input) {
var allInputsWithSameName = document.querySelectorAll('input[type="checkbox"][name="' + $input.name + '"]');
nodeListForEach(allInputsWithSameName, function ($inputWithSameName) {
var hasSameFormOwner = ($input.form === $inputWithSameName.form);
if (hasSameFormOwner && $inputWithSameName !== $input) {
$inputWithSameName.checked = false;
}
});
this.syncAllConditionalReveals();
};
/**
* Uncheck exclusive inputs
*
* Find any checkbox inputs with the same name value and the 'exclusive' behaviour,
* and uncheck them. This helps prevent someone checking both a regular checkbox and a
* "None of these" checkbox in the same fieldset.
*/
Checkboxes.prototype.unCheckExclusiveInputs = function ($input) {
var allInputsWithSameNameAndExclusiveBehaviour = document.querySelectorAll(
'input[data-behaviour="exclusive"][type="checkbox"][name="' + $input.name + '"]'
);
nodeListForEach(allInputsWithSameNameAndExclusiveBehaviour, function ($exclusiveInput) {
var hasSameFormOwner = ($input.form === $exclusiveInput.form);
if (hasSameFormOwner) {
$exclusiveInput.checked = false;
}
});
this.syncAllConditionalReveals();
};
/**
* Click event handler

@@ -1125,8 +1166,25 @@ *

// If a checkbox with aria-controls, handle click
var isCheckbox = $target.getAttribute('type') === 'checkbox';
// Ignore clicks on things that aren't checkbox inputs
if ($target.type !== 'checkbox') {
return
}
// If the checkbox conditionally-reveals some content, sync the state
var hasAriaControls = $target.getAttribute('aria-controls');
if (isCheckbox && hasAriaControls) {
if (hasAriaControls) {
this.syncConditionalRevealWithInputState($target);
}
// No further behaviour needed for unchecking
if (!$target.checked) {
return
}
// Handle 'exclusive' checkbox behaviour (ie "None of these")
var hasBehaviourExclusive = ($target.getAttribute('data-behaviour') === 'exclusive');
if (hasBehaviourExclusive) {
this.unCheckAllInputsExcept($target);
} else {
this.unCheckExclusiveInputs($target);
}
};

@@ -1133,0 +1191,0 @@

@@ -106,2 +106,8 @@ [

{
"name": "divider",
"type": "string",
"required": false,
"description": "Divider text to separate checkbox items, for example the text \"or\"."
},
{
"name": "checked",

@@ -125,2 +131,8 @@ "type": "boolean",

{
"name": "behaviour",
"type": "string",
"required": false,
"description": "If set to `exclusive`, implements a \"None of these\" type behaviour via javascript when checkboxes are clicked"
},
{
"name": "disabled",

@@ -127,0 +139,0 @@ "type": "boolean",

2

package.json
{
"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.12.0",
"version": "3.13.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 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 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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc