Skip to content

Commit

Permalink
Update behavior method names
Browse files Browse the repository at this point in the history
  • Loading branch information
anselmbradford committed Nov 6, 2024
1 parent a2c2925 commit 8ae891d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
17 changes: 4 additions & 13 deletions packages/cfpb-design-system/src/utilities/behavior/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function _findElements(behaviorSelector, baseElement) {
behaviorElements.length === 0 &&
behaviorSelector.indexOf(BEHAVIOR_PREFIX) === -1
) {
behaviorElements = find(behaviorSelector, baseElement);
behaviorElements = behaviorFind(behaviorSelector, baseElement);
}

return behaviorElements;
Expand All @@ -60,7 +60,7 @@ function _findElements(behaviorSelector, baseElement) {
* for the behavior element.
* @returns {Array|NodeList} if it exists in the dom, null otherwise.
*/
function attach(behaviorElement, event, eventHandler, baseElement) {
function behaviorAttach(behaviorElement, event, eventHandler, baseElement) {
let behaviorElements = [];

if (behaviorElement instanceof NodeList === true) {
Expand Down Expand Up @@ -118,21 +118,12 @@ function checkBehaviorDom(element, behaviorDataAttr) {
* for the behavior element.
* @returns {NodeList} if it exists in the dom, null otherwise.
*/
function find(behaviorSelector, baseElement) {
function behaviorFind(behaviorSelector, baseElement) {
behaviorSelector = JS_HOOK + '*=' + BEHAVIOR_PREFIX + behaviorSelector;
behaviorSelector = '[' + behaviorSelector + ']';

return _findElements(behaviorSelector, baseElement);
}

/**
* @param {HTMLElement} behaviorElement - Element in which to remove the event.
* @param {string} event - Event type to remove from the element.
* @param {Function} eventHandler - Callback for event.
*/
function remove(behaviorElement, event, eventHandler) {
behaviorElement.removeEventListener(event, eventHandler);
}

// Expose public methods.
export { attach, checkBehaviorDom, find, remove };
export { behaviorAttach, checkBehaviorDom, behaviorFind };
6 changes: 5 additions & 1 deletion packages/cfpb-design-system/src/utilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export { EventObserver } from './event-observer.js';

export { checkDom, instantiateAll, setInitFlag } from './atomic-helpers.js';

export { attach, checkBehaviorDom, find, remove } from './behavior/behavior.js';
export {
behaviorAttach,
checkBehaviorDom,
behaviorFind,
} from './behavior/behavior.js';

export {
isUndefined,
Expand Down

0 comments on commit 8ae891d

Please sign in to comment.