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

Commit 588ecc6

Browse files
committed
Avoid unnecessary global lookups of testingExposeCycleCount
1 parent 5979d82 commit 588ecc6

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/observe.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
(function(global) {
1616
'use strict';
1717

18+
var testingExposeCycleCount = global.testingExposeCycleCount;
19+
1820
// Detect and do basic sanity checking on Object/Array.observe.
1921
function detectObjectObserve() {
2022
if (typeof Object.observe !== 'function' ||
@@ -446,7 +448,7 @@
446448
while (cycles < MAX_DIRTY_CHECK_CYCLES && observer.check_()) {
447449
cycles++;
448450
}
449-
if (global.testingExposeCycleCount)
451+
if (testingExposeCycleCount)
450452
global.dirtyCheckCycleCount = cycles;
451453

452454
return cycles > 0;
@@ -845,7 +847,7 @@
845847
anyChanged = true;
846848
} while (cycles < MAX_DIRTY_CHECK_CYCLES && anyChanged);
847849

848-
if (global.testingExposeCycleCount)
850+
if (testingExposeCycleCount)
849851
global.dirtyCheckCycleCount = cycles;
850852

851853
runningMicrotaskCheckpoint = false;

tests/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
2222
<script src="../node_modules/chai/chai.js"></script>
2323
<script src="../node_modules/mocha/mocha.js"></script>
24+
25+
<script>window.testingExposeCycleCount = true</script>
2426
<script src="../src/observe.js"></script>
27+
2528
<script>
2629
mocha.setup({
2730
ui: 'tdd',

tests/test.js

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ var observer;
1616
var callbackArgs = undefined;
1717
var callbackInvoked = false;
1818

19-
window.testingExposeCycleCount = true;
20-
2119
function then(fn) {
2220
setTimeout(function() {
2321
Platform.performMicrotaskCheckpoint();

0 commit comments

Comments
 (0)