module.exports should default to an empty object.
Per the spec in modules.md the exports property should default to an empty object. We lazy allocate it so that modules that just replace it don't create the empty object and then throw it away. R=abarth@chromium.org Review URL: https://codereview.chromium.org/872043003
This commit is contained in:
parent
966b475029
commit
2808cfa418
@ -3,7 +3,9 @@
|
||||
<import src="../resources/dump-as-text.sky" />
|
||||
<div id="result">FAIL - Script did not execute</div>
|
||||
<script>
|
||||
document.getElementById("result").textContent =
|
||||
hello === undefined ? "PASS" : "FAIL";
|
||||
var result = "FAIL";
|
||||
if (typeof hello === "object" && Object.keys(hello).length === 0)
|
||||
result = "PASS";
|
||||
document.getElementById("result").textContent = result;
|
||||
</script>
|
||||
</html>
|
||||
|
@ -1,5 +1,6 @@
|
||||
Running 1 tests
|
||||
Running 2 tests
|
||||
ok 1 Module should be constructable
|
||||
1 tests
|
||||
1 pass
|
||||
ok 2 Module should have an empty object by default for exports
|
||||
2 tests
|
||||
2 pass
|
||||
0 fail
|
||||
|
@ -13,6 +13,13 @@ describe('Module', function() {
|
||||
assert.equal(module.document, doc2);
|
||||
assert.equal(module.url, "http://www.example.com/module");
|
||||
});
|
||||
|
||||
it('should have an empty object by default for exports', function() {
|
||||
var app = new Application(new Document(), "http://www.example.com/app");
|
||||
var module = new Module(app, new Document(), "http://www.example.com/module");
|
||||
assert.isObject(module.exports);
|
||||
assert.lengthOf(Object.keys(module.exports), 0);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user