Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

testcafe

Package Overview
Dependencies
Maintainers
4
Versions
464
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testcafe - npm Package Compare versions

Comparing version 0.11.1 to 0.12.0-alpha

94

lib/client-functions/selector-builder/add-api.js

@@ -70,2 +70,6 @@ 'use strict';

var _builderSymbol = require('../builder-symbol');
var _builderSymbol2 = _interopRequireDefault(_builderSymbol);
var _snapshotProperties = require('./snapshot-properties');

@@ -114,3 +118,3 @@

for (var j = 0; j < nodes.length; j++) {
if (filter(nodes[j])) result.push(nodes[j]);
if (filter(nodes[j], j)) result.push(nodes[j]);
}

@@ -350,2 +354,30 @@ }

function convertFilterToClientFunctionIfNecessary(callsiteName, filter, dependencies) {
if (typeof filter === 'function') {
var builder = filter[_builderSymbol2.default];
var fn = builder ? builder.fn : filter;
var options = builder ? (0, _lodash.assign)({}, builder.options, { dependencies: dependencies }) : { dependencies: dependencies };
return new _clientFunctionBuilder2.default(fn, options, { instantiation: callsiteName }).getFunction();
}
return filter;
}
function createDerivativeSelectorWithFilter(getSelector, SelectorBuilder, selectorFn, filter, additionalDependencies) {
var collectionModeSelectorBuilder = new SelectorBuilder(getSelector(), { collectionMode: true });
var dependencies = {
selector: collectionModeSelectorBuilder.getFunction(),
filter: filter,
filterNodes: filterNodes
};
dependencies = (0, _lodash.assign)(dependencies, additionalDependencies);
var builder = new SelectorBuilder(selectorFn, { dependencies: dependencies }, { instantiation: 'Selector' });
return builder.getFunction();
}
function addFilterMethods(obj, getSelector, SelectorBuilder) {

@@ -368,5 +400,7 @@ obj.nth = function (index) {

obj.filter = function (filter) {
obj.filter = function (filter, dependencies) {
(0, _typeAssertions.assertFunctionOrString)('filter', '"filter" argument', filter);
filter = convertFilterToClientFunctionIfNecessary('filter', filter, dependencies);
var selectorFn = function selectorFn() {

@@ -382,37 +416,13 @@ /* eslint-disable no-undef */

var collectionModeSelectorBuilder = new SelectorBuilder(getSelector(), { collectionMode: true });
var dependencies = {
selector: collectionModeSelectorBuilder.getFunction(),
filter: filter,
filterNodes: filterNodes
};
var builder = new SelectorBuilder(selectorFn, { dependencies: dependencies }, { instantiation: 'Selector' });
return builder.getFunction();
return createDerivativeSelectorWithFilter(getSelector, SelectorBuilder, selectorFn, filter);
};
}
function createHierachicalSelector(getSelector, SelectorBuilder, selectorFn, filter, additionalDependencies) {
var collectionModeSelectorBuilder = new SelectorBuilder(getSelector(), { collectionMode: true });
var dependencies = {
selector: collectionModeSelectorBuilder.getFunction(),
filter: filter,
expandSelectorResults: expandSelectorResults
};
dependencies = (0, _lodash.assign)(dependencies, additionalDependencies);
var builder = new SelectorBuilder(selectorFn, { dependencies: dependencies }, { instantiation: 'Selector' });
return builder.getFunction();
}
function addHierachicalSelectors(obj, getSelector, SelectorBuilder) {
// Find
obj.find = function (filter) {
obj.find = function (filter, dependencies) {
(0, _typeAssertions.assertFunctionOrString)('find', '"filter" argument', filter);
filter = convertFilterToClientFunctionIfNecessary('find', filter, dependencies);
var selectorFn = function selectorFn() {

@@ -433,3 +443,3 @@ /* eslint-disable no-undef */

if (filter(child)) results.push(child);
results.push(child);

@@ -442,3 +452,3 @@ visitNode(child);

return results;
return filterNodes(results, filter, null);
});

@@ -448,9 +458,11 @@ /* eslint-enable no-undef */

return createHierachicalSelector(getSelector, SelectorBuilder, selectorFn, filter);
return createDerivativeSelectorWithFilter(getSelector, SelectorBuilder, selectorFn, filter, { expandSelectorResults: expandSelectorResults });
};
// Parent
obj.parent = function (filter) {
obj.parent = function (filter, dependencies) {
if (filter !== void 0) (0, _typeAssertions.assertFunctionOrStringOnNonNegativeNumber)('parent', '"filter" argument', filter);
filter = convertFilterToClientFunctionIfNecessary('find', filter, dependencies);
var selectorFn = function selectorFn() {

@@ -468,9 +480,11 @@ /* eslint-disable no-undef */

return createHierachicalSelector(getSelector, SelectorBuilder, selectorFn, filter, { filterNodes: filterNodes });
return createDerivativeSelectorWithFilter(getSelector, SelectorBuilder, selectorFn, filter, { expandSelectorResults: expandSelectorResults });
};
// Child
obj.child = function (filter) {
obj.child = function (filter, dependencies) {
if (filter !== void 0) (0, _typeAssertions.assertFunctionOrStringOnNonNegativeNumber)('child', '"filter" argument', filter);
filter = convertFilterToClientFunctionIfNecessary('find', filter, dependencies);
var selectorFn = function selectorFn() {

@@ -493,9 +507,11 @@ /* eslint-disable no-undef */

return createHierachicalSelector(getSelector, SelectorBuilder, selectorFn, filter, { filterNodes: filterNodes });
return createDerivativeSelectorWithFilter(getSelector, SelectorBuilder, selectorFn, filter, { expandSelectorResults: expandSelectorResults });
};
// Sibling
obj.sibling = function (filter) {
obj.sibling = function (filter, dependencies) {
if (filter !== void 0) (0, _typeAssertions.assertFunctionOrStringOnNonNegativeNumber)('sibling', '"filter" argument', filter);
filter = convertFilterToClientFunctionIfNecessary('find', filter, dependencies);
var selectorFn = function selectorFn() {

@@ -522,3 +538,3 @@ /* eslint-disable no-undef */

return createHierachicalSelector(getSelector, SelectorBuilder, selectorFn, filter, { filterNodes: filterNodes });
return createDerivativeSelectorWithFilter(getSelector, SelectorBuilder, selectorFn, filter, { expandSelectorResults: expandSelectorResults });
};

@@ -525,0 +541,0 @@ }

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.11.1",
"version": "0.12.0-alpha",
"author": {

@@ -8,0 +8,0 @@ "name": "Developer Express Inc.",

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc