Skip to content

Commit

Permalink
2.0.0 release
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
danreeves committed Aug 11, 2015
1 parent 6e36211 commit 3dcf7fd
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 33 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@

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

## Breaking changes in 2.0.0

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.

Old syntax:

```
var plz = require('please-ajax')(window);
```

New syntax:

```
var plz = require('please-ajax');
```

## Features

- Small
Expand All @@ -25,7 +41,7 @@ Demo:
Basic:

```
var plz = require('please-ajax')(window);
var plz = require('please-ajax');
plz.get('http://danreev.es/', {
success: function (d) {
Expand Down
27 changes: 12 additions & 15 deletions dist/please.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
/**
* please-ajax - A small and modern AJAX library.
* @version v1.0.8
* @version v2.0.0
* @author Dan Reeves <[email protected]> (http://danreev.es/)
* @link https://github.com/fffunction/please
* @license MIT
*/
(function (root, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory;
} else {
root.please = factory(root);
}
})(this, function (root) {
(function () {
'use strict';

var exports = {};
Expand Down Expand Up @@ -85,7 +76,7 @@
}
};
} else {
var XHR = root.XMLHttpRequest || ActiveXObject;
var XHR = window.XMLHttpRequest || ActiveXObject;
request = new XHR('MSXML2.XMLHTTP.3.0');
request.open(type, url, true);
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
Expand Down Expand Up @@ -113,7 +104,7 @@
request.setRequestHeader(header, options.headers[header]);
}
}
if (!!root.Promise && options.promise) {
if (!!window.Promise && options.promise) {
return new Promise(function(resolve, reject) {
request.onload = function() {
if (request.status >= 200 && request.status < 300) {
Expand Down Expand Up @@ -161,6 +152,12 @@
return xhr('DELETE', url, false, options);
};

return exports;
if (typeof define === 'function' && define['amd']) {
define(function() { return exports; });
} else if (typeof module !== 'undefined' && module['exports']) {
module['exports'] = exports;
} else if (typeof this !== 'undefined') {
this['please'] = exports;
}

});
}).call(this);
2 changes: 1 addition & 1 deletion dist/please.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "please-ajax",
"version": "1.0.8",
"version": "2.0.0",
"description": "A small and modern AJAX library.",
"main": "dist/please.js",
"scripts": {
Expand Down
25 changes: 11 additions & 14 deletions src/please.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
(function (root, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory;
} else {
root.please = factory(root);
}
})(this, function (root) {
(function () {
'use strict';

var exports = {};
Expand Down Expand Up @@ -78,7 +69,7 @@
}
};
} else {
var XHR = root.XMLHttpRequest || ActiveXObject;
var XHR = window.XMLHttpRequest || ActiveXObject;
request = new XHR('MSXML2.XMLHTTP.3.0');
request.open(type, url, true);
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
Expand Down Expand Up @@ -106,7 +97,7 @@
request.setRequestHeader(header, options.headers[header]);
}
}
if (!!root.Promise && options.promise) {
if (!!window.Promise && options.promise) {
return new Promise(function(resolve, reject) {
request.onload = function() {
if (request.status >= 200 && request.status < 300) {
Expand Down Expand Up @@ -154,6 +145,12 @@
return xhr('DELETE', url, false, options);
};

return exports;
if (typeof define === 'function' && define['amd']) {
define(function() { return exports; });
} else if (typeof module !== 'undefined' && module['exports']) {
module['exports'] = exports;
} else if (typeof this !== 'undefined') {
this['please'] = exports;
}

});
}).call(this);
2 changes: 1 addition & 1 deletion tests/tests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var assert = require('assert'),
please = require('../dist/please.js')();
please = require('../dist/please.js');


describe('please', function () {
Expand Down

0 comments on commit 3dcf7fd

Please sign in to comment.