Skip to content

Commit 517fd77

Browse files
committed
Fix AMD bindings and fix AMD test.
v3.0.0 incorrectly passed the striptags function to `define`, when it should have passed in a module factory that returns the striptags function. See #24.
1 parent cd53825 commit 517fd77

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/striptags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204

205205
if (typeof define === 'function' && define.amd) {
206206
// AMD
207-
define([], striptags);
207+
define(function module_factory() { return striptags; });
208208
}
209209

210210
else if (typeof module === 'object' && module.exports) {

test/striptags-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ describe('striptags', function() {
1313
let src = fs.readFileSync(path);
1414
let script = new vm.Script(src);
1515

16-
it('should define a node module', function() {
16+
it('should define a Node module', function() {
1717
let module = { exports: {} };
1818

1919
script.runInNewContext({module});
2020

21-
assert.notEqual(module.exports, {});
21+
assert.equal(module.exports.toString(), striptags.toString());
2222
});
2323

24-
it('should define an amd module', function() {
25-
let global = {};
26-
let define = function(dependencies, module) {
27-
global.defined = module;
24+
it('should define an AMD module', function() {
25+
let module = null;
26+
let define = function(module_factory) {
27+
module = module_factory();
2828
};
2929

3030
define.amd = true;
3131

32-
script.runInNewContext({global, define});
32+
script.runInNewContext({define});
3333

34-
assert.notEqual(global.defined, null);
34+
assert.equal(module.toString(), striptags.toString());
3535
});
3636

3737
it('should define a browser global', function() {

0 commit comments

Comments
 (0)