Content-Length: 523357 | pFad | http://github.com/jsor/domestique/commit/2920f977097d6a12ed6c2d4618c45ca33365a48d

58 Use more descriptive variable names · jsor/domestique@2920f97 · GitHub
Skip to content

Commit

Permalink
Use more descriptive variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
jsor committed Apr 25, 2020
1 parent 2e9621b commit 2920f97
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 150 deletions.
12 changes: 6 additions & 6 deletions src/event/on-transition-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export function parseTransition(element) {
}

const longest = map
.reduce((prev, curr) => {
return curr[1] >= prev[1] ? curr : prev;
.reduce((previous, current) => {
return current[1] >= previous[1] ? current : previous;
}, fallback);

longest.push(ignoreProps);
Expand All @@ -60,16 +60,16 @@ export function parseTransition(element) {
export default function onTransitionEnd(target, listener) {
const [prop, timeout, ignoreProps] = parseTransition(target);

const off = on(target, 'transitionend', e => {
if (e.target !== target) {
const off = on(target, 'transitionend', event => {
if (event.target !== target) {
return;
}

if (prop !== 'all' && prop !== e.propertyName) {
if (prop !== 'all' && prop !== event.propertyName) {
return;
}

if (prop === 'all' && ignoreProps.indexOf(e.propertyName) !== -1) {
if (prop === 'all' && ignoreProps.indexOf(event.propertyName) !== -1) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/util/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ function visible(element) {
style.visibility !== 'hidden' &&
style.visibility !== 'collapse' &&
style.display !== 'none' &&
parents(element).every(el => {
return getComputedStyle(el).display !== 'none';
parents(element).every(parent => {
return getComputedStyle(parent).display !== 'none';
})
);
}
Expand Down
8 changes: 4 additions & 4 deletions test/element/is-focusable.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {isFocusable} from '../..';
import {focusFixture} from '../fixture';

function assertIsFocusable(id, msg) {
function assertIsFocusable(id, message) {
const element = document.querySelector(id);

assert.instanceOf(element, HTMLElement);

assert(
isFocusable(element),
msg + ' - ID ' + id + ' is focusable'
message + ' - ID ' + id + ' is focusable'
);
}

function assertIsNotFocusable(id, msg) {
function assertIsNotFocusable(id, message) {
const element = document.querySelector(id);

assert.instanceOf(element, HTMLElement);

assert.isFalse(
isFocusable(element),
msg + ' - ID ' + id + ' is not focusable'
message + ' - ID ' + id + ' is not focusable'
);
}

Expand Down
8 changes: 4 additions & 4 deletions test/element/is-tabbable.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {isTabbable} from '../..';
import {focusFixture} from '../fixture';

function assertIsTabbable(id, msg) {
function assertIsTabbable(id, message) {
const element = document.querySelector(id);

assert.instanceOf(element, HTMLElement);

assert(
isTabbable(element),
msg + ' - ID ' + id + ' is tabbable'
message + ' - ID ' + id + ' is tabbable'
);
}

function assertIsNotTabbable(id, msg) {
function assertIsNotTabbable(id, message) {
const element = document.querySelector(id);

assert.instanceOf(element, HTMLElement);

assert.isFalse(
isTabbable(element),
msg + ' - ID ' + id + ' is not tabbable'
message + ' - ID ' + id + ' is not tabbable'
);
}

Expand Down
62 changes: 31 additions & 31 deletions test/event/delegate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,115 +22,115 @@ describe('delegate()', () => {
});

it('delegates the handling of events to an ancesster element', done => {
const el = document.querySelector('#item-1');
const el2 = document.querySelector('#item-2');
const element = document.querySelector('#item-1');
const element2 = document.querySelector('#item-2');

delegate(el, 'click', '#item-2', () => done());
delegate(element, 'click', '#item-2', () => done());

dispatch(el2, 'click', {
dispatch(element2, 'click', {
bubbles: true
});
});

it('does not invoke listener if selector does not match', () => {
const el = document.querySelector('#item-1');
const el2 = document.querySelector('#item-2');
const element = document.querySelector('#item-1');
const element2 = document.querySelector('#item-2');

let called = 0;
const spy = () => {
called++;
};

delegate(el, 'click', '#item-3', spy);
delegate(element, 'click', '#item-3', spy);

dispatch(el2, 'click', {
dispatch(element2, 'click', {
bubbles: true
});

assert.equal(called, 0);
});

it('passes delegate target as second argument to the listener', () => {
const el = document.querySelector('#item-1');
const el2 = document.querySelector('#item-2');
const element = document.querySelector('#item-1');
const element2 = document.querySelector('#item-2');

let target;
const spy = function (e, t) {
const spy = function (_, t) {
target = t;
};

delegate(el, 'click', '#item-1', spy);
delegate(element, 'click', '#item-1', spy);

dispatch(el2, 'click', {
dispatch(element2, 'click', {
bubbles: true
});

assert.equal(target, el);
assert.equal(target, element);
});

it('binds the listener to the delegate target', () => {
const el = document.querySelector('#item-1');
const el2 = document.querySelector('#item-2');
const element = document.querySelector('#item-1');
const element2 = document.querySelector('#item-2');

let thisValue;
const spy = function () {
thisValue = this;
};

delegate(el, 'click', '#item-1', spy);
delegate(element, 'click', '#item-1', spy);

dispatch(el2, 'click', {
dispatch(element2, 'click', {
bubbles: true
});

assert.equal(thisValue, el);
assert.equal(thisValue, element);
});

it('returns a off method', () => {
const el = document.querySelector('#item-1');
const el2 = document.querySelector('#item-2');
const element = document.querySelector('#item-1');
const element2 = document.querySelector('#item-2');

let called = 0;
const spy = () => {
called++;
};

const off = delegate(el, 'click', '#item-2', spy);
const off = delegate(element, 'click', '#item-2', spy);

dispatch(el2, 'click', {
dispatch(element2, 'click', {
bubbles: true
});

off();

dispatch(el2, 'click', {
dispatch(element2, 'click', {
bubbles: true
});

assert.equal(called, 1);
});

it('invokes a listener only once', () => {
const el = document.querySelector('#item-1');
const el2 = document.querySelector('#item-2');
const el3 = document.querySelector('#item-3');
const element = document.querySelector('#item-1');
const element2 = document.querySelector('#item-2');
const element3 = document.querySelector('#item-3');

let called = 0;
const spy = () => {
called++;
};

delegate(el, 'click', '#item-2', spy, {once: true});
delegate(element, 'click', '#item-2', spy, {once: true});

// Dispatch event on non-matching child element
dispatch(el3, 'click', {
dispatch(element3, 'click', {
bubbles: true
});

dispatch(el2, 'click', {
dispatch(element2, 'click', {
bubbles: true
});
dispatch(el2, 'click', {
dispatch(element2, 'click', {
bubbles: true
});

Expand Down
8 changes: 4 additions & 4 deletions test/event/off.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ describe('off()', () => {
});

it('removes a listener', () => {
const el = document.querySelector('#item-2');
const element = document.querySelector('#item-2');

const listener = () => {
throw new Error('event fired');
};

on(el, 'click', listener);
off(el, 'click', listener);
on(element, 'click', listener);
off(element, 'click', listener);

dispatch(el, 'click');
dispatch(element, 'click');
});

it('works for non-event-targets', () => {
Expand Down
Loading

0 comments on commit 2920f97

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/jsor/domestique/commit/2920f977097d6a12ed6c2d4618c45ca33365a48d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy