Skip to content

Commit e5fe2a8

Browse files
committed
Update: Release 0.1.7
1 parent 36d1c4a commit e5fe2a8

6 files changed

Lines changed: 50 additions & 62 deletions

File tree

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# ShortQuery.js [![GitHub version](https://badge.fury.io/gh/S--Minecraft%2FShortQuery.js.svg)](https://badge.fury.io/gh/S--Minecraft%2FShortQuery.js)
2-
jsをほぼバニラで使用するためのただのショートハンドの集合体
3-
4-
Now only 2710Bytes!
5-
6-
Writing now...
2+
jsをほぼバニラで使用するためのただのショートハンドの集合体
3+
4+
Now only 3306Bytes!
5+
6+
## 対応ブラウザ
7+
IE11~
8+
Chrome49~
9+
10+
## ファイル
11+
`shortQuery.js` 本体
12+
`shortQuery.min.js` 上記の圧縮版
13+
`shortQuery.chrome.js` Chrome版(Chromeだけで使用する場合に最適化されています)
14+
`shortQuery.chrome.min.js` 上記の圧縮版

bin/shortQuery.chrome.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* ShortQuery.js v0.1.6-chrome MIT License
2+
* ShortQuery.js v0.1.7-chrome MIT License
33
* (C) 2015 S <https://github.com/S--Minecraft>
44
*/
55
/*
@@ -82,7 +82,8 @@
8282
};
8383

8484
ele.prototype.removeChildren = function() {
85-
this.element.textContent = null;
85+
this.textContent = null;
86+
return this;
8687
};
8788

8889
ele.prototype.getAttr = ele.prototype.getAttribute;
@@ -124,15 +125,18 @@
124125
};
125126

126127
ele.prototype.addClass = function(a) {
127-
return this.classList.add(a);
128+
this.classList.add(a);
129+
return this.classList;
128130
};
129131

130132
ele.prototype.removeClass = function(a) {
131-
return this.classList.remove(a);
133+
this.classList.remove(a);
134+
return this.classList;
132135
};
133136

134137
ele.prototype.toggleClass = function(a) {
135-
return this.classList.toggle(a);
138+
this.classList.toggle(a);
139+
return this.classList;
136140
};
137141

138142
ele.prototype.hasClass = function(a) {
@@ -170,13 +174,13 @@
170174
*/
171175

172176
exports.shortQuery = (function() {
173-
var class1;
177+
var ctor;
174178

175179
function shortQuery() {
176-
return class1.apply(this, arguments);
180+
return ctor.apply(this, arguments);
177181
}
178182

179-
class1 = d.querySelectorAll.bind(d);
183+
ctor = d.querySelectorAll.bind(d);
180184

181185
shortQuery.id = d.getElementById.bind(d);
182186

bin/shortQuery.chrome.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/shortQuery.js

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* ShortQuery.js v0.1.6 MIT License
2+
* ShortQuery.js v0.1.7 MIT License
33
* (C) 2015 S <https://github.com/S--Minecraft>
44
*/
55
/*
@@ -43,16 +43,10 @@
4343
*/
4444

4545
(function() {
46-
var ele, hasClassList, key;
46+
var ele;
4747

4848
ele = typeof HTMLElement !== "undefined" && HTMLElement !== null ? HTMLElement : Element;
4949

50-
for (key in ele.prototype) {
51-
if (key === "classList") {
52-
hasClassList = true;
53-
}
54-
}
55-
5650
ele.prototype.childClass = ele.prototype.getElementsByClassName;
5751

5852
ele.prototype.childTag = ele.prototype.getElementsByTagName;
@@ -88,7 +82,8 @@
8882
};
8983

9084
ele.prototype.removeChildren = function() {
91-
this.element.textContent = null;
85+
this.textContent = null;
86+
return this;
9287
};
9388

9489
ele.prototype.getAttr = ele.prototype.getAttribute;
@@ -108,18 +103,16 @@
108103
};
109104

110105
ele.prototype.getClass = function() {
111-
if (hasClassList) {
112-
return this.classList;
113-
} else {
114-
return this.className.split(" ");
115-
}
106+
return this.classList;
116107
};
117108

118109
ele.prototype.setClass = function(a) {
119-
if (a instanceof Array) {
120-
return this.className = a.join(" ");
110+
if (Array.isArray(a)) {
111+
this.className = a.join(" ");
112+
return this.classList;
121113
} else if (a != null) {
122-
return this.className = a;
114+
this.className = a;
115+
return this.classList;
123116
}
124117
};
125118

@@ -132,39 +125,22 @@
132125
};
133126

134127
ele.prototype.addClass = function(a) {
135-
if (hasClassList) {
136-
return this.classList.add(a);
137-
} else {
138-
if (!this.hasClass(a)) {
139-
this.className += " " + a;
140-
}
141-
return this.className.split(" ");
142-
}
128+
this.classList.add(a);
129+
return this.classList;
143130
};
144131

145132
ele.prototype.removeClass = function(a) {
146-
if (hasClassList) {
147-
return this.classList.remove(a);
148-
} else {
149-
this.className = this.className.replace(RegExp("^" + a + "$|" + a + " | " + a), "", "g");
150-
return this.className;
151-
}
133+
this.classList.remove(a);
134+
return this.classList;
152135
};
153136

154137
ele.prototype.toggleClass = function(a) {
155-
if (this.hasClass(a)) {
156-
return this.removeClass(a);
157-
} else {
158-
return this.addClass(a);
159-
}
138+
this.classList.toggle(a);
139+
return this.classList;
160140
};
161141

162142
ele.prototype.hasClass = function(a) {
163-
if (hasClassList) {
164-
return this.classList.contains(a);
165-
} else {
166-
return this.className.search(RegExp("^" + a + "$|" + a + " | " + a)) !== -1;
167-
}
143+
return this.classList.contains(a);
168144
};
169145

170146
}).call(this);
@@ -205,13 +181,13 @@
205181
*/
206182

207183
exports.shortQuery = (function() {
208-
var class1;
184+
var ctor;
209185

210186
function shortQuery() {
211-
return class1.apply(this, arguments);
187+
return ctor.apply(this, arguments);
212188
}
213189

214-
class1 = d.querySelectorAll.bind(d);
190+
ctor = d.querySelectorAll.bind(d);
215191

216192
shortQuery.id = d.getElementById.bind(d);
217193

bin/shortQuery.min.js

Lines changed: 2 additions & 2 deletions
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": "ShortQuery.js",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "Just a bundle of short-hand of vanilla js.",
55
"main": "bin/shortQuery.js",
66
"scripts": {

0 commit comments

Comments
 (0)