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

Commit 3cf0621

Browse files
author
John Messerly
committed
Merge pull request #82 from Arteris/exports_check
Check that exports global smells like we're inside a Node.js module
2 parents 061f240 + a81dcaa commit 3cf0621

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/observe.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1679,18 +1679,18 @@
16791679
return splices;
16801680
}
16811681

1682-
// Export the observe-js object for **Node.js**, with
1683-
// backwards-compatibility for the old `require()` API. If we're in
1684-
// the browser, export as a global object.
1682+
// Export the observe-js object for **Node.js**, with backwards-compatibility
1683+
// for the old `require()` API. Also ensure `exports` is not a DOM Element.
1684+
// If we're in the browser, export as a global object.
16851685

16861686
var expose = global;
16871687

1688-
if (typeof exports !== 'undefined') {
1688+
if (typeof exports !== 'undefined' && !exports.nodeType) {
16891689
if (typeof module !== 'undefined' && module.exports) {
1690-
expose = exports = module.exports;
1690+
exports = module.exports;
16911691
}
16921692
expose = exports;
1693-
}
1693+
}
16941694

16951695
expose.Observer = Observer;
16961696
expose.Observer.runEOM_ = runEOM;

0 commit comments

Comments
 (0)