Skip to content

Commit b2b5d68

Browse files
committed
fix DOMtastic tests
1 parent 7655fa7 commit b2b5d68

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

test/function_bind.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// https://github.com/ariya/phantomjs/issues/10522
2+
3+
// jshint ignore: start
4+
5+
if (!Function.prototype.bind) {
6+
Function.prototype.bind = function (oThis) {
7+
if (typeof this !== "function") {
8+
// closest thing possible to the ECMAScript 5 internal IsCallable function
9+
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
10+
}
11+
12+
var aArgs = Array.prototype.slice.call(arguments, 1),
13+
fToBind = this,
14+
fNOP = function () {},
15+
fBound = function () {
16+
return fToBind.apply(this instanceof fNOP && oThis
17+
? this
18+
: oThis,
19+
aArgs.concat(Array.prototype.slice.call(arguments)));
20+
};
21+
22+
fNOP.prototype = this.prototype;
23+
fBound.prototype = new fNOP();
24+
25+
return fBound;
26+
};
27+
}

test/lazyloadxt-domtastic.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="utf-8">
55
<title>Lazy Load XT Test Suite</title>
66
<!-- Load local jQuery. This can be overridden with a ?jquery=___ param. -->
7+
<script src="function_bind.js"></script>
78
<script src="../libs/domtastic/domtastic.js"></script>
89
<!-- Load local QUnit. -->
910
<link rel="stylesheet" href="../libs/qunit/qunit.css" media="screen">

test/lazyloadxt_test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
setTimeout(function () {
4141
var $img = $('img'),
4242
cntinit = $img.filter(function (index, el) {
43+
el = el || this;
4344
return $(el).data('lazied');
4445
}).length,
4546
cntnow = $img.filter(function (index, el) {
47+
el = el || this;
4648
return $(el).data('lazied') && ($(el).attr('src') === $(el).attr('data-src'));
4749
}).length;
4850
ok($img.length > 0, 'images should be presented');

0 commit comments

Comments
 (0)