Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Avoid unnecessary global lookups of testingExposeCycleCount
Browse files Browse the repository at this point in the history
  • Loading branch information
ajklein committed Aug 1, 2014
1 parent 5979d82 commit 588ecc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
(function(global) {
'use strict';

var testingExposeCycleCount = global.testingExposeCycleCount;

// Detect and do basic sanity checking on Object/Array.observe.
function detectObjectObserve() {
if (typeof Object.observe !== 'function' ||
Expand Down Expand Up @@ -446,7 +448,7 @@
while (cycles < MAX_DIRTY_CHECK_CYCLES && observer.check_()) {
cycles++;
}
if (global.testingExposeCycleCount)
if (testingExposeCycleCount)
global.dirtyCheckCycleCount = cycles;

return cycles > 0;
Expand Down Expand Up @@ -845,7 +847,7 @@
anyChanged = true;
} while (cycles < MAX_DIRTY_CHECK_CYCLES && anyChanged);

if (global.testingExposeCycleCount)
if (testingExposeCycleCount)
global.dirtyCheckCycleCount = cycles;

runningMicrotaskCheckpoint = false;
Expand Down
3 changes: 3 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
<script src="../node_modules/chai/chai.js"></script>
<script src="../node_modules/mocha/mocha.js"></script>

<script>window.testingExposeCycleCount = true</script>
<script src="../src/observe.js"></script>

<script>
mocha.setup({
ui: 'tdd',
Expand Down
2 changes: 0 additions & 2 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ var observer;
var callbackArgs = undefined;
var callbackInvoked = false;

window.testingExposeCycleCount = true;

function then(fn) {
setTimeout(function() {
Platform.performMicrotaskCheckpoint();
Expand Down

0 comments on commit 588ecc6

Please sign in to comment.