1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="../../dist/sizzle.js"></script>
<script>
var Sizzle1 = Sizzle;
</script>
<script src="../../dist/sizzle.js"></script>
<script>
var Sizzle2 = Sizzle;
</script>
</head>
<body>
<script>
var selector = "html > *",
elem = document.documentElement.firstChild,
expected = [],
originalSizzle = Sizzle,
sizzle1Selection = Sizzle1( selector ),
sizzle2Selection = Sizzle2( selector ),
replaced = Sizzle.noConflict();
do {
if ( elem.nodeType === 1 ) {
expected.push( elem );
}
} while ( (elem = elem.nextSibling) );
window.parent.iframeCallback( function( assert ) {
assert.notStrictEqual( originalSizzle, Sizzle1, "first Sizzle overwritten" );
assert.deepEqual( sizzle1Selection, expected, "selection by first Sizzle" );
assert.deepEqual( sizzle2Selection, expected, "selection by second Sizzle" );
assert.strictEqual( Sizzle, Sizzle1, "first Sizzle restored by noConflict" );
assert.strictEqual( replaced, Sizzle2, "second Sizzle returned by noConflict" );
assert.deepEqual( Sizzle1( selector ), expected, "another selection by first Sizzle" );
assert.deepEqual( Sizzle2( selector ), expected, "another selection by second Sizzle" );
} );
</script>
</body>
</html>
|