aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/desandro/imagesloaded/test/unit/non-element.js
blob: 4c9986fa68dc30185e760b78178f30a63b33be5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
QUnit.test( 'dismiss non-element nodes', function( assert ) {
  'use strict';

  var $ = window.jQuery;
  var done = assert.async( 2 );

  $(' <img src="https://picsum.photos/401/301/?random" /> <img src="https://picsum.photos/402/302/?random" /> ')
    .imagesLoaded(function() {
      assert.ok( true, 'elements from jQuery string ok' );
      done();
    });

  // test fragment
  var frag = document.createDocumentFragment();
  var img = new Image();
  img.src = 'https://picsum.photos/403/303/?random';
  frag.appendChild( img );
  var imgLoad = imagesLoaded( frag, function() {
    assert.ok( true, 'document fragment ok' );
    assert.equal( imgLoad.images.length, 1, '1 image found' );
    done();
  });

});