Revision control

1
<script src="../resources/magnitude-perf.js"></script>
2
<script>
3
4
var element, className, classToRemove;
5
6
// Test 1 tests that remove is linear when there are N class names.
7
8
function setupFunction1(magnitude)
9
{
10
element = document.createElement('div');
11
classToRemove = 'b';
12
className = Array(magnitude).join('a ') + classToRemove;
13
}
14
15
// Test 2 tests that remove is linear when the length of the class name is N.
16
17
function setupFunction2(magnitude)
18
{
19
element = document.createElement('div');
20
classToRemove = Array(magnitude + 1).join('a');
21
className = classToRemove;
22
}
23
24
function test(magnitude)
25
{
26
element.className = className;
27
element.classList.remove(classToRemove);
28
}
29
30
Magnitude.description('Tests that classList remove is linear.');
31
Magnitude.run(setupFunction1, test, Magnitude.LINEAR);
32
Magnitude.run(setupFunction2, test, Magnitude.LINEAR);
33
34
</script>
35
</body>