Skip to content

Commit 3dcf7fd

Browse files
committed
2.0.0 release
Updates module code to work with webpack. This new style removes the need to initialise with window (e.g `require('please-ajax')(window)`) which is a breaking change, hence 2.0.0, and removes compatibility with node. I decided that was safe, since this modules biggest feature is the form uploads that support IE9. Remind me to write docs for that...
1 parent 6e36211 commit 3dcf7fd

File tree

6 files changed

+43
-33
lines changed

6 files changed

+43
-33
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55

66
[![Build Status](https://travis-ci.org/fffunction/please.svg?branch=master)](https://travis-ci.org/fffunction/please)
77

8+
## Breaking changes in 2.0.0
9+
10+
It's no longer necessary to init with the window value. The library now references the window directly, since it'll always be used in a browser.
11+
12+
Old syntax:
13+
14+
```
15+
var plz = require('please-ajax')(window);
16+
```
17+
18+
New syntax:
19+
20+
```
21+
var plz = require('please-ajax');
22+
```
23+
824
## Features
925

1026
- Small
@@ -25,7 +41,7 @@ Demo:
2541
Basic:
2642

2743
```
28-
var plz = require('please-ajax')(window);
44+
var plz = require('please-ajax');
2945
3046
plz.get('http://danreev.es/', {
3147
success: function (d) {

dist/please.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
/**
22
* please-ajax - A small and modern AJAX library.
3-
* @version v1.0.8
3+
* @version v2.0.0
44
* @author Dan Reeves <[email protected]> (http://danreev.es/)
55
* @link https://github.com/fffunction/please
66
* @license MIT
77
*/
8-
(function (root, factory) {
9-
'use strict';
10-
if (typeof define === 'function' && define.amd) {
11-
define(factory);
12-
} else if (typeof exports === 'object') {
13-
module.exports = factory;
14-
} else {
15-
root.please = factory(root);
16-
}
17-
})(this, function (root) {
8+
(function () {
189
'use strict';
1910

2011
var exports = {};
@@ -85,7 +76,7 @@
8576
}
8677
};
8778
} else {
88-
var XHR = root.XMLHttpRequest || ActiveXObject;
79+
var XHR = window.XMLHttpRequest || ActiveXObject;
8980
request = new XHR('MSXML2.XMLHTTP.3.0');
9081
request.open(type, url, true);
9182
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
@@ -113,7 +104,7 @@
113104
request.setRequestHeader(header, options.headers[header]);
114105
}
115106
}
116-
if (!!root.Promise && options.promise) {
107+
if (!!window.Promise && options.promise) {
117108
return new Promise(function(resolve, reject) {
118109
request.onload = function() {
119110
if (request.status >= 200 && request.status < 300) {
@@ -161,6 +152,12 @@
161152
return xhr('DELETE', url, false, options);
162153
};
163154

164-
return exports;
155+
if (typeof define === 'function' && define['amd']) {
156+
define(function() { return exports; });
157+
} else if (typeof module !== 'undefined' && module['exports']) {
158+
module['exports'] = exports;
159+
} else if (typeof this !== 'undefined') {
160+
this['please'] = exports;
161+
}
165162

166-
});
163+
}).call(this);

dist/please.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "please-ajax",
3-
"version": "1.0.8",
3+
"version": "2.0.0",
44
"description": "A small and modern AJAX library.",
55
"main": "dist/please.js",
66
"scripts": {

src/please.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
(function (root, factory) {
2-
'use strict';
3-
if (typeof define === 'function' && define.amd) {
4-
define(factory);
5-
} else if (typeof exports === 'object') {
6-
module.exports = factory;
7-
} else {
8-
root.please = factory(root);
9-
}
10-
})(this, function (root) {
1+
(function () {
112
'use strict';
123

134
var exports = {};
@@ -78,7 +69,7 @@
7869
}
7970
};
8071
} else {
81-
var XHR = root.XMLHttpRequest || ActiveXObject;
72+
var XHR = window.XMLHttpRequest || ActiveXObject;
8273
request = new XHR('MSXML2.XMLHTTP.3.0');
8374
request.open(type, url, true);
8475
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
@@ -106,7 +97,7 @@
10697
request.setRequestHeader(header, options.headers[header]);
10798
}
10899
}
109-
if (!!root.Promise && options.promise) {
100+
if (!!window.Promise && options.promise) {
110101
return new Promise(function(resolve, reject) {
111102
request.onload = function() {
112103
if (request.status >= 200 && request.status < 300) {
@@ -154,6 +145,12 @@
154145
return xhr('DELETE', url, false, options);
155146
};
156147

157-
return exports;
148+
if (typeof define === 'function' && define['amd']) {
149+
define(function() { return exports; });
150+
} else if (typeof module !== 'undefined' && module['exports']) {
151+
module['exports'] = exports;
152+
} else if (typeof this !== 'undefined') {
153+
this['please'] = exports;
154+
}
158155

159-
});
156+
}).call(this);

tests/tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var assert = require('assert'),
4-
please = require('../dist/please.js')();
4+
please = require('../dist/please.js');
55

66

77
describe('please', function () {

0 commit comments

Comments
 (0)