mirror of
https://github.com/jquery/jquery.git
synced 2024-12-09 08:04:24 +00:00
9cb124ed00
So far, we've been testing that jQuery element iteration works with polyfilled Symbol & transpiled for-of via a Node test with jsdom with the Symbol global removed. Unfortunately, jsdom now requires Symbol to be present for its internal functionality so such a test is no longer possible. Instead, it's been migrated to an iframe test with transpiled JavaScript. This PR also enables us to use ECMAScript 2017 or newer in Node.js code. Closes gh-4305
46 lines
988 B
JavaScript
46 lines
988 B
JavaScript
"use strict";
|
|
|
|
const { JSDOM } = require( "jsdom" );
|
|
|
|
const { window } = new JSDOM( "" );
|
|
|
|
const jQuery = require( "../../" )( window );
|
|
|
|
module.exports.deferred = () => {
|
|
let adopted, promised;
|
|
|
|
return {
|
|
resolve: function() {
|
|
if ( !adopted ) {
|
|
adopted = jQuery.when.apply( jQuery, arguments );
|
|
if ( promised ) {
|
|
adopted.then( promised.resolve, promised.reject );
|
|
}
|
|
}
|
|
return adopted;
|
|
},
|
|
reject: function( value ) {
|
|
if ( !adopted ) {
|
|
adopted = jQuery.when( jQuery.Deferred().reject( value ) );
|
|
if ( promised ) {
|
|
adopted.then( promised.resolve, promised.reject );
|
|
}
|
|
}
|
|
return adopted;
|
|
},
|
|
|
|
// A manually-constructed thenable that works even if calls precede resolve/reject
|
|
promise: {
|
|
then: function() {
|
|
if ( !adopted ) {
|
|
if ( !promised ) {
|
|
promised = jQuery.Deferred();
|
|
}
|
|
return promised.then.apply( promised, arguments );
|
|
}
|
|
return adopted.then.apply( adopted, arguments );
|
|
}
|
|
}
|
|
};
|
|
};
|