Skip to content

Commit

Permalink
Drop support of IE 6 - 9
Browse files Browse the repository at this point in the history
Closes #370
  • Loading branch information
carhartl committed Sep 5, 2019
1 parent a9222c1 commit d811fec
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 97 deletions.
3 changes: 1 addition & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ module.exports = function (grunt) {
eslint: {
grunt: 'Gruntfile.js',
source: 'src/**/*.js',
tests: ['test/**/*.js', '!test/polyfill.js']
tests: 'test/**/*.js'
},
uglify: {
options: {
compress: {
unsafe: true
},
screwIE8: false,
banner: '/*! <%= pkg.name %> v<%= pkg.version %> | <%= pkg.license %> */\n'
},
build: {
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ Cookies.getJSON('name'); // => { foo: 'bar' }
Cookies.getJSON(); // => { name: { foo: 'bar' } }
```

*Note: To support IE6-7 ([and IE 8 compatibility mode](http://stackoverflow.com/questions/4715373/json-object-undefined-in-internet-explorer-8)) you need to include the JSON-js polyfill: https://github.com/douglascrockford/JSON-js*

## Encoding

This project is [RFC 6265](http://tools.ietf.org/html/rfc6265#section-4.1.1) compliant. All special characters that are not allowed in the cookie-name or cookie-value are encoded with each one's UTF-8 Hex equivalent using [percent-encoding](http://en.wikipedia.org/wiki/Percent-encoding).
Expand Down
1 change: 0 additions & 1 deletion browserstack.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"firefox_previous",
"ie_11",
"ie_10",
"ie_9",
"opera_latest",
{
"browser": "safari",
Expand Down
1 change: 0 additions & 1 deletion test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"lifecycle": true,
"using": true,
"quoted": true,
"addEvent": true,
"loadFileSync": true
},
"rules": {}
Expand Down
1 change: 0 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
<script>Cookies = 'existent global'</script>
<script src="../build/js.cookie.min.js"></script>
<script src="polyfill.js"></script>
<script src="utils.js"></script>
<script src="tests.js"></script>
</head>
Expand Down
17 changes: 0 additions & 17 deletions test/malformed_cookie.html

This file was deleted.

31 changes: 0 additions & 31 deletions test/polyfill.js

This file was deleted.

30 changes: 2 additions & 28 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,6 @@ QUnit.test('percent character in cookie value mixed with encoded values', functi
assert.strictEqual(Cookies.get('bad'), 'foo%bar"baz%bax=', 'should read the percent character');
});

// github.com/carhartl/jquery-cookie/pull/88
// github.com/carhartl/jquery-cookie/pull/117
QUnit.test('malformed cookie value in IE', function (assert) {
assert.expect(1);
var done = assert.async();
// Sandbox in an iframe so that we can poke around with document.cookie.
var iframe = document.createElement('iframe');
iframe.src = 'malformed_cookie.html';
addEvent(iframe, 'load', function () {
if (iframe.contentWindow.ok) {
assert.strictEqual(iframe.contentWindow.testValue, 'two', 'reads all cookie values, skipping duplicate occurences of "; "');
} else {
// Skip the test where we can't stub document.cookie using
// Object.defineProperty. Seems to work fine in
// Chrome, Firefox and IE 8+.
assert.ok(true, 'N/A');
}
done();
});
document.body.appendChild(iframe);
});

// github.com/js-cookie/js-cookie/pull/171
QUnit.test('missing leading semicolon', function (assert) {
assert.expect(1);
Expand All @@ -74,7 +52,7 @@ QUnit.test('missing leading semicolon', function (assert) {
var loadedSuccessfully = true;
iframe.src = 'missing_semicolon.html';

addEvent(iframe, 'load', function () {
iframe.addEventListener('load', function () {
iframe.contentWindow.onerror = function () {
loadedSuccessfully = false;
};
Expand Down Expand Up @@ -133,11 +111,7 @@ QUnit.test('Call to read cookie when there is a window.json variable globally',
window.json = true;
Cookies.set('boolean', true);
assert.strictEqual(typeof Cookies.get('boolean'), 'string', 'should not change the returned type');
// IE 6-8 throw an exception if trying to delete a window property
// See stackoverflow.com/questions/1073414/deleting-a-window-property-in-ie/1824228
try {
delete window.json;
} catch (e) {}
delete window.json;
});

QUnit.module('write', lifecycle);
Expand Down
15 changes: 1 addition & 14 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
window.lifecycle = {
afterEach: function () {
// Remove the cookies created using js-cookie default attributes
// Note: Using `Object.keys(Cookies.get()).forEach(Cookies.remove)`
// would cause IE 6 + 7 to break with a "Object doesn't support
// this property or method" error, thus wrapping it with a
// function.
Object.keys(Cookies.get()).forEach(function (cookie) {
Cookies.remove(cookie);
});
Expand All @@ -20,15 +16,6 @@
}
};

window.addEvent = function (element, eventName, fn) {
var method = 'addEventListener';
if (element.attachEvent) {
eventName = 'on' + eventName;
method = 'attachEvent';
}
element[ method ](eventName, fn);
};

window.using = function (assert) {
function getQuery(key) {
var queries = location.href.split('?')[1];
Expand Down Expand Up @@ -58,7 +45,7 @@
'&value=' + encodeURIComponent(value)
].join('');
var done = assert.async();
addEvent(iframe, 'load', function () {
iframe.addEventListener('load', function () {
var iframeDocument = iframe.contentWindow.document;
var root = iframeDocument.documentElement;
var content = root.textContent;
Expand Down

4 comments on commit d811fec

@FagnerMartinsBrack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@FagnerMartinsBrack
Copy link
Member

@FagnerMartinsBrack FagnerMartinsBrack commented on d811fec Sep 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might also be able to remove some source code bytes that were only added for the sake of IE

@carhartl
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FagnerMartinsBrack I thought so too, looking at the source I didn‘t notice anything obvious.

@FagnerMartinsBrack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carhartl We have enough coverage. Therefore, once Browserstack is setup we can start golfing it :D

Please sign in to comment.