domtokenlist-shim
Advanced tools
Comparing version 1.1.0 to 1.1.1
# Changelog | ||
## 1.1.1 (2015-11-25) | ||
* Fixed illegal `relList` constructor. (props [@TrySound](https://github.com/TrySound)) | ||
@@ -3,0 +5,0 @@ ## 1.1.0 (2015-05-31) |
@@ -52,6 +52,2 @@ /*! DOMTokenlist shim | Copyright 2015 Jonathan Wilsson and Bogdan Chadkin. */ | ||
if (window.DOMTokenList) { | ||
return; | ||
} | ||
var arr = []; | ||
@@ -58,0 +54,0 @@ |
/*! DOMTokenlist shim | Copyright 2015 Jonathan Wilsson and Bogdan Chadkin. */ | ||
!function(t){"use strict";if(t.DOMTokenList){var e=document.createElement("a").classList,n=DOMTokenList.prototype,i=n.add,r=n.remove,o=n.toggle;e.add("c1","c2");var s=function(t){return function(){var e,n=arguments;for(e=0;e<n.length;e+=1)t.call(this,n[e])}};e.contains("c2")||(n.add=s(i),n.remove=s(r)),e.toggle("c1",!0)||(n.toggle=function(t,e){return void 0===e?o.call(this,t):((e?i:r).call(this,t),!!e)})}}(window),function(t){"use strict";if(!t.DOMTokenList){var e=[],n=function(t,n){var i;if(e.indexOf)return e.indexOf.call(t,n);for(i=0;i<t.length;i++)if(t[i]===n)return i;return-1},i=function(t){var e=/[\u0009\u000A\u000C\u000D\u0020]/;if(""===t||e.test(t))throw new Error("Token must not be empty or contain whitespace.")},r=function(t,e){var n,i=this,r=[];if(t&&e&&(i.element=t,i.prop=e,t[e]))for(r=t[e].replace(/^\s+|\s+$/g,"").split(/\s+/),n=0;n<r.length;n++)i[n]=r[n];i.length=r.length};r.prototype={add:function(){var t,n=this,r=arguments;for(t=0;t<r.length;t++)i(r[t]),n.contains(r[t])||e.push.call(n,r[t]);n.element&&(n.element[n.prop]=n)},contains:function(t){return i(t),-1!==n(this,t)},item:function(t){return this[t]||null},remove:function(){var t,r,o=arguments,s=this;for(r=0;r<o.length;r++)i(o[r]),t=n(s,o[r]),-1!==t&&e.splice.call(s,t,1);s.element&&(s.element[s.prop]=s)},toggle:function(t,e){var n=this;return n.contains(t)?e?!0:(n.remove(t),!1):e===!1?!1:(n.add(t),!0)},toString:function(){return e.join.call(this," ")}},t.DOMTokenList=r}}(window),function(){"use strict";"classList"in document.createElement("a")&&!window.QUnit||Object.defineProperty(Element.prototype,"classList",{get:function(){return new DOMTokenList(this,"className")}})}(),function(){"use strict";if(!("relList"in document.createElement("a"))||window.QUnit){var t,e=[HTMLAnchorElement,HTMLAreaElement,HTMLLinkElement],n=function(){return new DOMTokenList(this,"rel")};for(t=0;t<e.length;t++)Object.defineProperty(e[t].prototype,"relList",{get:n})}}(); | ||
!function(t){"use strict";if(t.DOMTokenList){var e=document.createElement("a").classList,n=DOMTokenList.prototype,r=n.add,i=n.remove,o=n.toggle;e.add("c1","c2");var c=function(t){return function(){var e,n=arguments;for(e=0;e<n.length;e+=1)t.call(this,n[e])}};e.contains("c2")||(n.add=c(r),n.remove=c(i)),e.toggle("c1",!0)||(n.toggle=function(t,e){return void 0===e?o.call(this,t):((e?r:i).call(this,t),!!e)})}}(window),function(t){"use strict";var e=[],n=function(t,n){var r;if(e.indexOf)return e.indexOf.call(t,n);for(r=0;r<t.length;r++)if(t[r]===n)return r;return-1},r=function(t){var e=/[\u0009\u000A\u000C\u000D\u0020]/;if(""===t||e.test(t))throw new Error("Token must not be empty or contain whitespace.")},i=function(t,e){var n,r=this,i=[];if(t&&e&&(r.element=t,r.prop=e,t[e]))for(i=t[e].replace(/^\s+|\s+$/g,"").split(/\s+/),n=0;n<i.length;n++)r[n]=i[n];r.length=i.length};i.prototype={add:function(){var t,n=this,i=arguments;for(t=0;t<i.length;t++)r(i[t]),n.contains(i[t])||e.push.call(n,i[t]);n.element&&(n.element[n.prop]=n)},contains:function(t){return r(t),-1!==n(this,t)},item:function(t){return this[t]||null},remove:function(){var t,i,o=arguments,c=this;for(i=0;i<o.length;i++)r(o[i]),t=n(c,o[i]),-1!==t&&e.splice.call(c,t,1);c.element&&(c.element[c.prop]=c)},toggle:function(t,e){var n=this;return n.contains(t)?e?!0:(n.remove(t),!1):e===!1?!1:(n.add(t),!0)},toString:function(){return e.join.call(this," ")}},t.DOMTokenList=i}(window),function(){"use strict";"classList"in document.createElement("a")&&!window.QUnit||Object.defineProperty(Element.prototype,"classList",{get:function(){return new DOMTokenList(this,"className")}})}(),function(){"use strict";if(!("relList"in document.createElement("a"))||window.QUnit){var t,e=[HTMLAnchorElement,HTMLAreaElement,HTMLLinkElement],n=function(){return new DOMTokenList(this,"rel")};for(t=0;t<e.length;t++)Object.defineProperty(e[t].prototype,"relList",{get:n})}}(); |
@@ -10,6 +10,9 @@ var gulp = require('gulp'); | ||
var files = './src/**/*.js'; | ||
var files = ['src/DOMTokenList-newest.js', 'src/DOMTokenList.js', 'src/classList.js', 'src/relList.js']; | ||
gulp.task('concat', ['lint'], function () { | ||
gulp.task('build', function () { | ||
return gulp.src(files) | ||
.pipe(jscs()) | ||
.pipe(jshint()) | ||
.pipe(jshint.reporter('default')) | ||
.pipe(concat('domtokenlist.js')) | ||
@@ -20,17 +23,3 @@ .pipe(header('/*! DOMTokenlist shim | Copyright <%= new Date().getFullYear() %> Jonathan Wilsson and Bogdan Chadkin. */\n')) | ||
})) | ||
.pipe(gulp.dest('./dist')); | ||
}); | ||
gulp.task('lint', function () { | ||
return gulp.src(files) | ||
.pipe(jscs()) | ||
.on('error', function (err) { | ||
console.log(err.message); | ||
}) | ||
.pipe(jshint()) | ||
.pipe(jshint.reporter('default')); | ||
}); | ||
gulp.task('uglify', ['concat'], function () { | ||
return gulp.src('dist/domtokenlist.js') | ||
.pipe(gulp.dest('dist')) | ||
.pipe(uglify({ | ||
@@ -45,9 +34,9 @@ preserveComments: 'some' | ||
})) | ||
.pipe(gulp.dest('./dist')); | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('watch', ['default'], function () { | ||
gulp.watch(files, ['default']); | ||
gulp.task('dev', ['build'], function () { | ||
gulp.watch(files, ['build']) | ||
}); | ||
gulp.task('default', ['uglify']); | ||
gulp.task('default', ['build']); |
{ | ||
"name": "domtokenlist-shim", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A super strict shim/polyfill for DOMTokenList", | ||
@@ -17,11 +17,12 @@ "keywords": [ | ||
"devDependencies": { | ||
"gulp": "~3.8.11", | ||
"gulp-concat": "~2.5.2", | ||
"gulp-header": "~1.2.2", | ||
"gulp-jscs": "^1.6.0", | ||
"gulp-jshint": "~1.10.0", | ||
"gulp-rename": "~1.2.2", | ||
"gulp-size": "^1.2.1", | ||
"gulp-uglify": "~1.2.0", | ||
"qunitjs": "~1.18.0" | ||
"browserstack-runner": "^0.3.5", | ||
"gulp": "^3.9.0", | ||
"gulp-concat": "^2.5.2", | ||
"gulp-header": "^1.2.2", | ||
"gulp-jscs": "^3.0.0", | ||
"gulp-jshint": "^1.11.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-size": "^2.0.0", | ||
"gulp-uglify": "^1.2.0", | ||
"qunitjs": "^1.18.0" | ||
}, | ||
@@ -28,0 +29,0 @@ "author": "Jonathan Wilsson <jonathan.wilsson@gmail.com>", |
# DOMTokenList shim | ||
A super strict shim/polyfill for [DOMTokenList](http://dom.spec.whatwg.org/#interface-domtokenlist), classList and relList. | ||
A super strict shim/polyfill for [DOMTokenList](http://dom.spec.whatwg.org/#interface-domtokenlist), classList and relList. Small, < 1 kB minified and gzipped (~ 2kB minified). | ||
@@ -5,0 +5,0 @@ ## Usage |
;(function (window) { | ||
'use strict'; | ||
if (window.DOMTokenList) { | ||
return; | ||
} | ||
var arr = []; | ||
@@ -9,0 +5,0 @@ |
@@ -180,2 +180,10 @@ module('DOMTokenList'); | ||
test('Test toggle force = true with filled token list', function () { | ||
var list = new DOMTokenList(); | ||
list.add('token-1'); | ||
equal(list.toggle('token-1', true), true, 'Assert that toggle returns true.'); | ||
}); | ||
test('Test toggle force = true with empty token list', function () { | ||
@@ -182,0 +190,0 @@ var list = new DOMTokenList(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1004404
25
702
10
226