-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decaffeinate: Run post-processing cleanups on jquery.coffee and 1 oth…
…er file
- Loading branch information
Showing
2 changed files
with
439 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}) |
Oops, something went wrong.