Keine Beschreibung

jquery.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Use the right jQuery source on the test page (and iframes)
  2. ( function() {
  3. /* global loadTests: false */
  4. var config, src,
  5. FILEPATH = "/test/jquery.js",
  6. activeScript = [].slice.call( document.getElementsByTagName( "script" ), -1 )[ 0 ],
  7. parentUrl = activeScript && activeScript.src ?
  8. activeScript.src.replace( /[?#].*/, "" ) + FILEPATH.replace( /[^/]+/g, ".." ) + "/" :
  9. "../",
  10. QUnit = window.QUnit,
  11. require = window.require;
  12. function getQUnitConfig() {
  13. var config = Object.create( null );
  14. // Default to unminified jQuery for directly-opened iframes
  15. if ( !QUnit ) {
  16. config.dev = true;
  17. } else {
  18. // QUnit.config is populated from QUnit.urlParams but only at the beginning
  19. // of the test run. We need to read both.
  20. QUnit.config.urlConfig.forEach( function( entry ) {
  21. config[ entry.id ] = QUnit.config[ entry.id ] != null ?
  22. QUnit.config[ entry.id ] :
  23. QUnit.urlParams[ entry.id ];
  24. } );
  25. }
  26. return config;
  27. }
  28. // Define configuration parameters controlling how jQuery is loaded
  29. if ( QUnit ) {
  30. QUnit.config.urlConfig.push( {
  31. id: "amd",
  32. label: "Load with AMD",
  33. tooltip: "Load the AMD jQuery file (and its dependencies)"
  34. }, {
  35. id: "dev",
  36. label: "Load unminified",
  37. tooltip: "Load the development (unminified) jQuery file"
  38. } );
  39. }
  40. config = getQUnitConfig();
  41. src = config.dev ?
  42. "dist/jquery.js" :
  43. "dist/jquery.min.js";
  44. // Honor AMD loading on the main window (detected by seeing QUnit on it).
  45. // This doesn't apply to iframes because they synchronously expect jQuery to be there.
  46. if ( config.amd && QUnit ) {
  47. require.config( {
  48. baseUrl: parentUrl
  49. } );
  50. src = "src/jquery";
  51. // Include tests if specified
  52. if ( typeof loadTests !== "undefined" ) {
  53. require( [ src ], loadTests );
  54. } else {
  55. require( [ src ] );
  56. }
  57. // Otherwise, load synchronously
  58. } else {
  59. document.write( "<script id='jquery-js' nonce='jquery+hardcoded+nonce' src='" + parentUrl + src + "'><\x2Fscript>" );
  60. }
  61. } )();