@cfpb/cfpb-atomic-component
Advanced tools
Comparing version 0.21.0 to 0.21.1
{ | ||
"name": "@cfpb/cfpb-atomic-component", | ||
"version": "0.21.0", | ||
"version": "0.21.1", | ||
"description": "Design System atomic component utilities", | ||
@@ -16,4 +16,4 @@ "less": "src/cfpb-atomic-component.less", | ||
], | ||
"gitHead": "905c9fa959cdf19f992fabfc0b3f5f64b315d67e", | ||
"gitHead": "0f38eede5bf9e16ed629aa5581b6107575b5480d", | ||
"type": "module" | ||
} |
@@ -338,2 +338,9 @@ /* eslint-disable no-use-before-define */ | ||
/** | ||
* Set the transition that runs when this flyout is expanded/collapsed. | ||
* | ||
* @param {BaseTransition} transition - A transition object. | ||
* @param {Function} collapseMethod - The collapse method to call on the transition. | ||
* @param {Function} expandMethod - The expand method to call on the transition. | ||
*/ | ||
function setTransition(transition, collapseMethod, expandMethod) { | ||
@@ -340,0 +347,0 @@ _transition = transition; |
@@ -5,2 +5,21 @@ import { JS_HOOK } from './standard-type.js'; | ||
* @param {HTMLElement} element - DOM element. | ||
* @param {string} value - Value to check as existing as a JS data-* hook value. | ||
* @returns {boolean} True if the data-* hook value exists, false otherwise. | ||
*/ | ||
function contains(element, value) { | ||
if (!element) { | ||
return false; | ||
} | ||
let values = element.getAttribute(JS_HOOK); | ||
// If JS data-* hook is not set return immediately. | ||
if (!values) { | ||
return false; | ||
} | ||
values = values.split(' '); | ||
return values.indexOf(value) > -1 ? true : false; | ||
} | ||
/** | ||
* @param {HTMLElement} element - DOM element. | ||
* @param {string} value - Value to add to the element's JS data-* hook. | ||
@@ -12,2 +31,4 @@ * @returns {string} The value that was added. | ||
function add(element, value) { | ||
if (contains(element, value)) return value; | ||
if (value.indexOf(' ') !== -1) { | ||
@@ -45,21 +66,2 @@ const msg = JS_HOOK + ' values cannot contain spaces!'; | ||
/** | ||
* @param {HTMLElement} element - DOM element. | ||
* @param {string} value - Value to check as existing as a JS data-* hook value. | ||
* @returns {boolean} True if the data-* hook value exists, false otherwise. | ||
*/ | ||
function contains(element, value) { | ||
if (!element) { | ||
return false; | ||
} | ||
let values = element.getAttribute(JS_HOOK); | ||
// If JS data-* hook is not set return immediately. | ||
if (!values) { | ||
return false; | ||
} | ||
values = values.split(' '); | ||
return values.indexOf(value) > -1 ? true : false; | ||
} | ||
export { add, contains, remove }; |
@@ -10,3 +10,3 @@ /** | ||
* @param {object} classes - The classes to apply to this transition. | ||
* @param {Object} child - The child transition using this as a base. | ||
* @param {object} child - The child transition using this as a base. | ||
* @returns {BaseTransition} An instance. | ||
@@ -18,3 +18,3 @@ */ | ||
if (!child) throw new Error('Child transition argument must be defined!'); | ||
let _child = child; | ||
const _child = child; | ||
@@ -21,0 +21,0 @@ let _lastClass; |
72030
1750