function elementFromPoint(self, document, x, y) { scope.renderAllPending(); var element = wrap(originalElementFromPoint.call(unsafeUnwrap(document), x, y)); if (!element) return null; var path = getEventPath(element, null); var idx = path.lastIndexOf(self); if (idx == -1) return null; else path = path.slice(0, idx); return eventRetargetting(path, self); }
it('has correct name', function () { proclaim.hasName(Array.prototype.lastIndexOf, 'lastIndexOf'); });
export function isButtonValueDisabled(buttonName, buttonValue, activeFilter, filteredItems) { let activeButtons = Object.keys(activeFilter), isLastActiveButton = activeButtons.lastIndexOf(buttonName) === activeButtons.length - 1, isFilterGroupButton = buttonName === 'group', isValueSelectalable = validateValue(filteredItems, { [buttonName]: buttonValue }) return !isLastActiveButton && !isFilterGroupButton && !isValueSelectalable }
it('returns -1 when no match is found', function() { proclaim.equal(Array.prototype.lastIndexOf.call([], 3), -1); proclaim.equal(Array.prototype.lastIndexOf.call([], null), -1); proclaim.equal(Array.prototype.lastIndexOf.call([], undefined), -1); proclaim.equal(Array.prototype.lastIndexOf.call(['foo'], 'bar'), -1); });
it('takes 1 argument', function() { proclaim.equal(Array.prototype.lastIndexOf.length, 1); });
/* globals proclaim */ it('is a function', function () { proclaim.isFunction(Array.prototype.lastIndexOf); });
it('returns the index when a match is found', function() { proclaim.equal(Array.prototype.lastIndexOf.call(['foo'], 'foo'), 0); proclaim.equal(Array.prototype.lastIndexOf.call([3,4], 4), 1); });
it('has correct arity', function () { proclaim.arity(Array.prototype.lastIndexOf, 1); });
it('finds only the last occurence', function() { proclaim.equal(Array.prototype.lastIndexOf.call(['foo', 'bar', 'bar', 'bar'], 'bar'), 3); });
it('is a function', function() { proclaim.isInstanceOf(Array.prototype.lastIndexOf, Function); });
function elementFromPoint(self, document, x, y) { scope.renderAllPending(); var element = wrap(originalElementFromPoint.call(unsafeUnwrap(document), x, y)); if (!element) return null; var path = getEventPath(element, null); var idx = path.lastIndexOf(self); if (idx == -1) return null; else path = path.slice(0, idx); return eventRetargetting(path, self); }
function elementFromPoint(self, document, x, y) { scope.renderAllPending(); var element = wrap(originalElementFromPoint.call(unsafeUnwrap(document), x, y)); if (!element) return null; var path = getEventPath(element, null); var idx = path.lastIndexOf(self); if (idx == -1) return null; else path = path.slice(0, idx); return eventRetargetting(path, self); }
function elementFromPoint(self, document, x, y) { scope.renderAllPending(); var element = wrap(originalElementFromPoint.call(unsafeUnwrap(document), x, y)); if (!element) return null; var path = getEventPath(element, null); var idx = path.lastIndexOf(self); if (idx == -1) return null; else path = path.slice(0, idx); return eventRetargetting(path, self); }
it('works on array-like objects', function() { proclaim.equal(Array.prototype.lastIndexOf.call({0:5,1:6,length:2}, 6), 1); proclaim.equal(Array.prototype.lastIndexOf.call({0:5,1:6,2:7,length:2}, 7), -1); });
it('does not find nested arrays', function() { proclaim.equal(Array.prototype.lastIndexOf.call([1,2,[3,3]], [3,3]), -1); });