getAll.js 650 B

1234567891011121314151617181920212223242526272829303132
  1. define( [
  2. "../core",
  3. "../core/nodeName"
  4. ], function( jQuery, nodeName ) {
  5. "use strict";
  6. function getAll( context, tag ) {
  7. // Support: IE <=9 - 11 only
  8. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  9. var ret;
  10. if ( typeof context.getElementsByTagName !== "undefined" ) {
  11. ret = context.getElementsByTagName( tag || "*" );
  12. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  13. ret = context.querySelectorAll( tag || "*" );
  14. } else {
  15. ret = [];
  16. }
  17. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  18. return jQuery.merge( [ context ], ret );
  19. }
  20. return ret;
  21. }
  22. return getAll;
  23. } );