Skip to content

Commit 3cdac75

Browse files
committed
Tests: Use a data attribute for stylesheets
1 parent 8b3d752 commit 3cdac75

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

tests/unit/accordion/accordion.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
<meta charset="utf-8">
55
<title>jQuery UI Accordion Test Suite</title>
66

7-
<script src="../helper/css.js"></script>
8-
<script>
9-
window.helper.loadCss([ "core", "accordion" ]);
10-
</script>
7+
<script src="../helper/css.js" data-modules="core accordion"></script>
118

129
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
1310
<style>

tests/unit/helper/css.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
(function() {
22

3-
if( !window.helper ) {
4-
window.helper = {};
5-
}
6-
73
function includeStyle( url ) {
84
document.write( "<link rel='stylesheet' href='../../../" + url + "'>" );
95
}
106

11-
window.helper.loadCss = function( styles ) {
12-
var i;
13-
for( i = 0; i < styles.length; i++ ) {
14-
includeStyle( "themes/base/" + styles[ i ] + ".css" );
15-
}
16-
};
7+
var scripts = document.getElementsByTagName( "script" );
8+
var script = scripts[ scripts.length - 1 ];
9+
var modules = script.getAttribute( "data-modules" ).split( /\s+/ );
10+
var i = 0;
11+
12+
for ( ; i < modules.length; i++ ) {
13+
document.write( "<link rel='stylesheet' href='../../../themes/base/" + modules[ i ] + ".css'>" );
14+
}
1715

18-
}());
16+
} )();

0 commit comments

Comments
 (0)