Skip to content

Commit

Permalink
decaffeinate: Run post-processing cleanups on jquery.coffee and 1 oth…
Browse files Browse the repository at this point in the history
…er file
  • Loading branch information
kuceb committed Aug 1, 2019
1 parent 9c9748c commit 8808b54
Show file tree
Hide file tree
Showing 2 changed files with 439 additions and 386 deletions.
99 changes: 48 additions & 51 deletions packages/driver/src/config/jquery.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,70 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const $ = require("jquery");
const _ = require('lodash');
require("jquery.scrollto");
const $ = require('jquery')
const _ = require('lodash')

const $dom = require("../dom");
require('jquery.scrollto')

//# force jquery to have the same visible
//# and hidden logic as cypress
const $dom = require('../dom')

//# this prevents `is` from calling into the native .matches method
//# which would prevent our `focus` code from ever being called during
//# is(:focus).
//# see https://github.com/jquery/sizzle/wiki#sizzlematchesselector-domelement-element-string-selector-
// force jquery to have the same visible
// and hidden logic as cypress

//# this is to help to interpretor make optimizations around try/catch
const tryCatchFinally = function({tryFn, catchFn, finallyFn}) {
// this prevents `is` from calling into the native .matches method
// which would prevent our `focus` code from ever being called during
// is(:focus).
// see https://github.com/jquery/sizzle/wiki#sizzlematchesselector-domelement-element-string-selector-

// this is to help to interpretor make optimizations around try/catch
const tryCatchFinally = function ({ tryFn, catchFn, finallyFn }) {
try {
return tryFn();
return tryFn()
} catch (e) {
return catchFn(e);
}
finally {
finallyFn();
return catchFn(e)
} finally {
finallyFn()
}
};
}

const { matchesSelector } = $.find

$.find.matchesSelector = function (elem, expr) {
let supportMatchesSelector
const isUsingFocus = _.includes(expr, ':focus')

const { matchesSelector } = $.find;
$.find.matchesSelector = function(elem, expr) {
let supportMatchesSelector;
const isUsingFocus = _.includes(expr, ':focus');
if (isUsingFocus) {
supportMatchesSelector = $.find.support.matchesSelector;
$.find.support.matchesSelector = false;
supportMatchesSelector = $.find.support.matchesSelector
$.find.support.matchesSelector = false
}

const args = arguments;
const _this = this;
// eslint-disable-next-line prefer-rest-params
const args = arguments
const _this = this

return tryCatchFinally({
tryFn() {
return matchesSelector.apply(_this, args);
tryFn () {
return matchesSelector.apply(_this, args)
},
catchFn(e) {
throw e;
catchFn (e) {
throw e
},
finallyFn() {
finallyFn () {
if (isUsingFocus) {
return $.find.support.matchesSelector = supportMatchesSelector;
$.find.support.matchesSelector = supportMatchesSelector
}
}
});
};

},
})
}

//# see difference between 'filters' and 'pseudos'
//# https://api.jquery.com/filter/ and https://api.jquery.com/category/selectors/
// see difference between 'filters' and 'pseudos'
// https://api.jquery.com/filter/ and https://api.jquery.com/category/selectors/

$.expr.pseudos.focus = $dom.isFocused;
$.expr.filters.focus = $dom.isFocused;
$.expr.pseudos.focused = $dom.isFocused;
$.expr.filters.visible = $dom.isVisible;
$.expr.filters.hidden = $dom.isHidden;
$.expr.pseudos.focus = $dom.isFocused
$.expr.filters.focus = $dom.isFocused
$.expr.pseudos.focused = $dom.isFocused
$.expr.filters.visible = $dom.isVisible
$.expr.filters.hidden = $dom.isHidden

$.expr.cacheLength = 1;
$.expr.cacheLength = 1

$.ajaxSetup({
cache: false
});
cache: false,
})
Loading

0 comments on commit 8808b54

Please sign in to comment.