├── .babelrc
├── .eslintignore
├── .eslintrc
├── .gitignore
├── .npmignore
├── README.md
├── bower.json
├── dist
├── clus.js
├── clus.js.map
├── clus.min.js
└── clus.min.js.map
├── package.json
├── rollup.config.js
├── src
├── ajax.js
├── core
│ ├── core.js
│ ├── extend.js
│ └── init.js
├── css.js
├── dom.js
├── event.js
├── global.js
├── index.js
├── instance.js
└── search.js
├── test
├── index.html
└── unit
│ └── core.js
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015-rollup"]
3 | }
4 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | src/sizzle/sizzle.js
2 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "ecmaFeatures": {
4 | "modules": true
5 | },
6 | "env": {
7 | "es6": true,
8 | "browser": true,
9 | "node": true,
10 | "mocha": true
11 | },
12 | "globals": {
13 | "Clus": true
14 | },
15 | "parser": "babel-eslint",
16 | "rules": {
17 | "semi": [2, "always"],
18 | "quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
19 | "comma-dangle": [2, "always-multiline"],
20 | "no-console": [0, { allow: ["warn", "error"] }],
21 | "no-multiple-empty-lines": [2, { "max": 1 }]
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .npm-debug.log
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | src
3 | test
4 | bower.json
5 | rollup.config.js
6 | index.html
7 | .babelrc
8 | .eslintrc
9 | .eslintignore
10 | .gitignore
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Clus - A minimalist JavaScript library for modern browsers.
2 |
3 | [](https://david-dm.org/justclear/clus#info=dependencies&view=table)
4 | [](https://david-dm.org/justclear/clus#info=devDependencies&view=table)
5 |
6 | ## Emoji Commit
7 |
8 | Commit Type | Emoji
9 | ----------------------- | -------------
10 | Initial Commit | :tada: `:tada:`
11 | Structure | :art: `:art:`
12 | Documentation | :memo: `:memo:`
13 | New Idea | :bulb: `:bulb:`
14 | New Feature | :sparkles: `:sparkles:`
15 | Bug | :bug: `:bug:`
16 | Version Tag | :bookmark: `:bookmark:`
17 | Performance | :racehorse: `:racehorse:`
18 | Tooling | :wrench: `:wrench:`
19 | Tests | :rotating_light: `:rotating_light:`
20 | Deprecation | :poop: `:poop:`
21 | Work In Progress (WIP) | :construction: `:construction:`
22 | Upgrading | :arrow_up: `:arrow_up:`
23 |
24 | Example:
25 |
26 | > ":art: fixing coding standard"
27 |
28 | ## Usage
29 |
30 | ### Install
31 |
32 | ```sh
33 | $ npm i clus --save
34 | # or
35 | $ bower i clus
36 | ```
37 |
38 | ### Global methods
39 |
40 | - `$.ajax()`
41 | - `$.each()`
42 | - `$.map()`
43 |
44 | ### Instance methods
45 |
46 | - `.ready()`
47 | - `.addClass()`
48 | - `.removeClass()`
49 | - `.hasClass()`
50 | - `.toggleClass()`
51 | - `.append()`
52 | - `.appendTo()`
53 | - `.parent()`
54 | - `.parents()`
55 | - `.children()`
56 | - `.each()`
57 | - `.map()`
58 | - `.on()`
59 | - `.off()`
60 | - `.trigger()`
61 | - `.width()`
62 | - `.height()`
63 |
64 | ### DOM
65 |
66 |
67 | #### `$(document).ready()`
68 |
69 | ```js
70 | $(document).ready(function () {
71 | // DOM is ready
72 | });
73 |
74 | // or
75 |
76 | $(function () {
77 | // DOM is ready
78 | });
79 | ```
80 |
81 |
82 | #### `.addClass(className)`
83 |
84 | Example:
85 |
86 | ```js
87 | $('.hello').addClass('world');
88 | $('p').addClass('hello world');
89 | // or
90 | $('p').addClass('hello').addClass('world');
91 | ```
92 |
93 |
94 | #### `.removeClass(className)`
95 |
96 | Example:
97 |
98 | ```js
99 | $('.hello').removeClass('hello').addClass('hi');
100 | $('p').addClass('hello world').removeClass('hello world');
101 | // or
102 | $('p').addClass('hello world').removeClass('hello').removeClass('world');
103 | ```
104 |
105 |
106 | #### `.hasClass(className)`
107 |
108 | Example:
109 |
110 | ```js
111 | $('p').hasClass('hello'); // true
112 | $('p').hasClass('world'); // false
113 | ```
114 |
115 |
116 | #### `.toggleClass(className)`
117 |
118 | Example:
119 |
120 | ```js
121 | $('p').toggleClass('hello');
122 | ```
123 |
124 |
125 | #### `.append(DOMString)`
126 |
127 | Example:
128 |
129 | ```js
130 | $('body').append('
Hello Clus
');
131 | ```
132 |
133 |
134 | #### `.appendTo(selector)`
135 |
136 | Example:
137 |
138 | ```js
139 | $('Hello Clus
').appendTo('body');
140 | ```
141 |
142 |
143 | #### `.parent()`
144 |
145 | Example:
146 |
147 | ```js
148 | $('.hello').parent();
149 | ```
150 |
151 |
152 | #### `.parents()`
153 |
154 | Example:
155 |
156 | ```js
157 | $('.hello').parents();
158 | $('.hello').parents('body');
159 | ```
160 |
161 |
162 | #### `.children()`
163 |
164 | Example:
165 |
166 | ```js
167 | $('.hello').children();
168 | $('.hello').children('.world');
169 | ```
170 |
171 |
172 | #### `$.each()`
173 |
174 | Example:
175 |
176 | ```js
177 | $.each(['just', 'hello', 'world'], function (item, index) {
178 | console.log(item, index);
179 | });
180 | // just 0
181 | // hello 1
182 | // world 2
183 | ```
184 |
185 |
186 | #### `.each()`
187 |
188 | Example:
189 |
190 | ```js
191 | $('.hello').each(function (item, index) {
192 | $(this).addClass('world');
193 | console.log($(this));
194 | });
195 | ```
196 |
197 |
198 | #### `$.map()`
199 |
200 | Example:
201 |
202 | ```js
203 | $.map(['just', 'hello', 'world'], function (item, index) {
204 | console.log(item, index);
205 | });
206 | // just 0
207 | // hello 1
208 | // world 2
209 | ```
210 |
211 |
212 | #### `.map()`
213 |
214 | Example:
215 |
216 | ```js
217 | $('.hello').map(function (item, index) {
218 | $(this).addClass('world');
219 | console.log($(this));
220 | });
221 | ```
222 |
223 |
224 | #### `.on()`
225 |
226 | Example:
227 |
228 | ```js
229 | $('.hello').on('click', function () {
230 | console.log($(this));
231 | });
232 |
233 | $(document).on('click', '.hello', function () {
234 | console.log($(this));
235 | });
236 | ```
237 |
238 |
239 | #### `.off()`
240 |
241 | Example:
242 |
243 | ```js
244 | let hello = function () {
245 | console.log('hello');
246 | }
247 | $(document).on('click', '.hello', hello);
248 | $(document).off('click', '.hello', hello);
249 | ```
250 |
251 |
252 | #### `.trigger()`
253 |
254 | Example:
255 |
256 | ```js
257 | let data = {
258 | hello: 'hello',
259 | };
260 | $(document).on('hello', function (event) {
261 | console.log(event.detail); // { hello: "hello" }
262 | });
263 | $(document).trigger('hello', data);
264 | ```
265 |
266 |
267 | #### `.ajax()`
268 |
269 | Example:
270 |
271 | ```js
272 | $.ajax({
273 | type: 'GET',
274 | url: 'http://api.hello.com', // http://api.hello.com/?hello=hello&world=world
275 | data: {
276 | hello: 'hello',
277 | world: 'world',
278 | },
279 | success: function (data) {
280 | console.log(data);
281 | },
282 | error: function (error) {
283 | console.error(error);
284 | },
285 | });
286 | ```
287 |
288 |
289 | #### `.width()`
290 |
291 | Example:
292 |
293 | ```js
294 | $(window).width()
295 | $(document).width()
296 | $('body').width()
297 | ```
298 |
299 |
300 | #### `.height()`
301 |
302 | Example:
303 |
304 | ```js
305 | $(window).height()
306 | $(document).height()
307 | $('body').height()
308 | ```
309 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clus",
3 | "description": "A minimalist JavaScript library for modern browsers.",
4 | "main": "dist/clus.js",
5 | "authors": [
6 | "JustClear"
7 | ],
8 | "license": "MIT",
9 | "keywords": [
10 | "clus",
11 | "library",
12 | "class",
13 | "dom"
14 | ],
15 | "homepage": "https://github.com/JustClear/clus",
16 | "ignore": [
17 | "**/.*",
18 | ".*",
19 | "rollup.*.js",
20 | "*.json",
21 | "*.md",
22 | "*.yml",
23 | "node_modules",
24 | "bower_components",
25 | "src",
26 | "test",
27 | "tests"
28 | ]
29 | }
30 |
--------------------------------------------------------------------------------
/dist/clus.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
3 | typeof define === 'function' && define.amd ? define('Clus', factory) :
4 | (factory());
5 | }(this, (function () { 'use strict';
6 |
7 | //
8 | // initialize
9 | //
10 |
11 | /**
12 | * Initialize
13 | *
14 | * @method init
15 | * @param {String} selector
16 | * @return {DOM} DOMList
17 | */
18 | function init(selector) {
19 | var dom = void 0,
20 | fragmentRE = /^\s*<(\w+|!)[^>]*>/,
21 | selectorType = Clus.type(selector),
22 | elementTypes = [1, 9, 11];
23 |
24 | if (!selector) {
25 | dom = [], dom.selector = selector;
26 | } else if (elementTypes.indexOf(selector.nodeType) !== -1 || selector === window) {
27 | dom = [selector], selector = null;
28 | } else if (selectorType === 'function') {
29 | return Clus(document).ready(selector);
30 | } else if (selectorType === 'array') {
31 | dom = selector;
32 | } else if (selectorType === 'object') {
33 | dom = [selector], selector = null;
34 | } else if (selectorType === 'string') {
35 | if (selector[0] === '<' && fragmentRE.test(selector)) {
36 | dom = Clus.parseHTML(selector), selector = null;
37 | } else {
38 | dom = [].slice.call(document.querySelectorAll(selector));
39 | }
40 | }
41 |
42 | dom = dom || [];
43 | Clus.extend(dom, Clus.fn);
44 | dom.selector = selector;
45 |
46 | return dom;
47 | }
48 |
49 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
50 | return typeof obj;
51 | } : function (obj) {
52 | return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
53 | };
54 |
55 | //
56 | // extend
57 | //
58 |
59 | /**
60 | * Extend object
61 | *
62 | * @method extend
63 | * @return {Object} object
64 | */
65 | function extend() {
66 | var options = void 0,
67 | name = void 0,
68 | clone = void 0,
69 | copy = void 0,
70 | source = void 0,
71 | copyIsArray = void 0,
72 | target = arguments[0] || {},
73 | i = 1,
74 | length = arguments.length,
75 | deep = false;
76 |
77 | if (typeof target === 'boolean') {
78 | deep = target;
79 | target = arguments[i] || {};
80 | i++;
81 | }
82 |
83 | if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' && Clus.type(target) !== 'function') {
84 | target = {};
85 | }
86 |
87 | if (i === length) {
88 | target = this;
89 | i--;
90 | }
91 |
92 | for (; i < length; i++) {
93 | //
94 | if ((options = arguments[i]) !== null) {
95 | // for in source object
96 | for (name in options) {
97 |
98 | source = target[name];
99 | copy = options[name];
100 |
101 | if (target == copy) {
102 | continue;
103 | }
104 |
105 | // deep clone
106 | if (deep && copy && (Clus.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
107 | // if copy is array
108 | if (copyIsArray) {
109 | copyIsArray = false;
110 | // if is not array, set it to array
111 | clone = source && Array.isArray(source) ? source : [];
112 | } else {
113 | // if copy is not a object, set it to object
114 | clone = source && Clus.isPlainObject(source) ? source : {};
115 | }
116 |
117 | target[name] = extend(deep, clone, copy);
118 | } else if (copy !== undefined) {
119 | target[name] = copy;
120 | }
121 | }
122 | }
123 | }
124 |
125 | return target;
126 | }
127 |
128 | //
129 | // core
130 | //
131 |
132 | /**
133 | * Constructor
134 | *
135 | * @constructor Clus
136 | * @method Clus
137 | * @param {String} selector
138 | */
139 | function Clus$1(selector) {
140 | return new Clus$1.fn.init(selector);
141 | }
142 |
143 | Clus$1.fn = Clus$1.prototype = {
144 | contructor: Clus$1,
145 | init: init
146 | };
147 |
148 | Clus$1.fn.init.prototype = Clus$1.fn;
149 |
150 | Clus$1.extend = Clus$1.fn.extend = extend;
151 |
152 | window.Clus = window.C = window.$ = Clus$1;
153 |
154 | //
155 | // global methods
156 | //
157 |
158 | function rootQuery(selector) {
159 | return document.querySelectorAll(selector);
160 | }
161 |
162 | function trim(text) {
163 | var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
164 | return text == null ? '' : ('' + text).replace(rtrim, '');
165 | }
166 |
167 | function type(object) {
168 | var class2type = {},
169 | type = class2type.toString.call(object),
170 | typeString = 'Boolean Number String Function Array Date RegExp Object Error Symbol';
171 |
172 | if (object == null) {
173 | return object + '';
174 | }
175 |
176 | typeString.split(' ').forEach(function (type) {
177 | class2type['[object ' + type + ']'] = type.toLowerCase();
178 | });
179 |
180 | return (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' || typeof object === 'function' ? class2type[type] || 'object' : typeof object === 'undefined' ? 'undefined' : _typeof(object);
181 | }
182 |
183 | function isPlainObject(object) {
184 | var proto = void 0,
185 | ctor = void 0,
186 | class2type = {},
187 | toString = class2type.toString,
188 | // Object.prototype.toString
189 | hasOwn = class2type.hasOwnProperty,
190 | fnToString = hasOwn.toString,
191 | // Object.toString/Function.toString
192 | ObjectFunctionString = fnToString.call(Object); // 'function Object() { [native code] }'
193 |
194 | if (!object || toString.call(object) !== '[object Object]') {
195 | return false;
196 | }
197 |
198 | // According to the object created by `Object.create(null)` is no `prototype`
199 | proto = Object.getPrototypeOf(object);
200 | if (!proto) {
201 | return true;
202 | }
203 |
204 | ctor = hasOwn.call(proto, 'constructor') && proto.constructor;
205 | return typeof ctor === 'function' && fnToString.call(ctor) === ObjectFunctionString;
206 | }
207 |
208 | function isWindow(object) {
209 | return object !== null && object === object.window;
210 | }
211 |
212 | function isDocument(object) {
213 | return object !== null && object.nodeType == object.DOCUMENT_NODE;
214 | }
215 |
216 | function isArrayLike(object) {
217 | var len = !!object && 'length' in object && object.length,
218 | type = Clus.type(object);
219 |
220 | if (type === 'function' || isWindow(object)) return false;
221 |
222 | return type === 'array' || len === 0 || typeof length === 'number' && len > 0 && len - 1 in object;
223 | }
224 |
225 | function flatten(array) {
226 | var ret = [],
227 | el = void 0,
228 | i = 0,
229 | len = array.length;
230 |
231 | for (; i < len; i++) {
232 | el = array[i];
233 | if (Array.isArray(el)) {
234 | ret.push.apply(ret, flatten(el));
235 | } else {
236 | ret.push(el);
237 | }
238 | }
239 | return ret;
240 | }
241 |
242 | function map(items, callback) {
243 | var value = void 0,
244 | values = [],
245 | len = void 0,
246 | i = 0;
247 |
248 | if (isArrayLike(items)) {
249 | len = items.length;
250 | for (; i < len; i++) {
251 | value = callback(items[i], i);
252 | if (value != null) values.push(value);
253 | }
254 | } else {
255 | for (i in items) {
256 | value = callback(items[i], i);
257 | if (value != null) values.push(value);
258 | }
259 | }
260 |
261 | return flatten(values);
262 | }
263 |
264 | function each(items, callback) {
265 | var len = void 0,
266 | i = 0;
267 |
268 | if (isArrayLike(items)) {
269 | len = items.length;
270 | for (; i < len; i++) {
271 | if (callback.call(items[i], items[i], i) === false) return items;
272 | }
273 | } else {
274 | for (i in items) {
275 | if (callback.call(items[i], items[i], i) === false) return items;
276 | }
277 | }
278 |
279 | return items;
280 | }
281 |
282 | function merge(first, second) {
283 | var len = +second.length,
284 | j = 0,
285 | i = first.length;
286 |
287 | for (; j < len; j++) {
288 | first[i++] = second[j];
289 | }
290 |
291 | first.length = i;
292 |
293 | return first;
294 | }
295 |
296 | function unique(array) {
297 | var unique = [],
298 | i = 0,
299 | len = array.length;
300 | for (; i < len; i++) {
301 | if (unique.indexOf(array[i]) === -1) {
302 | unique.push(array[i]);
303 | }
304 | }
305 | return unique;
306 | }
307 |
308 | function matches(element, selector) {
309 | if (!selector || !element || element.nodeType !== 1) return false;
310 |
311 | var matchesSelector = element.matchesSelector || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector;
312 |
313 | return matchesSelector.call(element, selector);
314 | }
315 |
316 | function parseHTML(DOMString) {
317 | var htmlDoc = document.implementation.createHTMLDocument();
318 | htmlDoc.body.innerHTML = DOMString;
319 | return htmlDoc.body.children;
320 | }
321 |
322 | Clus.extend({
323 | find: rootQuery,
324 | type: type,
325 | isPlainObject: isPlainObject,
326 | isWindow: isWindow,
327 | isDocument: isDocument,
328 | isArrayLike: isArrayLike,
329 | each: each,
330 | map: map,
331 | merge: merge,
332 | trim: trim,
333 | unique: unique,
334 | matches: matches,
335 | parseHTML: parseHTML
336 | });
337 |
338 | //
339 | // instance methods
340 | //
341 |
342 | function is(selector) {
343 | return this.length > 0 && Clus.matches(this[0], selector);
344 | }
345 |
346 | function instanceMap(callback) {
347 | return Clus(Clus.map(this, function (item, index) {
348 | return callback.call(item, item, index);
349 | }));
350 | }
351 |
352 | function instanceEach(callback) {
353 | [].every.call(this, function (item, index) {
354 | return callback.call(item, item, index) !== false;
355 | });
356 | return this;
357 | }
358 |
359 | Clus.fn.extend({
360 | is: is,
361 | map: instanceMap,
362 | each: instanceEach
363 | });
364 |
365 | //
366 | // event
367 | //
368 |
369 | function on(eventName, selector, handler, capture) {
370 | var events = eventName.split(' '),
371 | i = void 0,
372 | j = void 0;
373 |
374 | for (i = 0; i < this.length; i++) {
375 | if (Clus.type(selector) === 'function' || selector === false) {
376 | // Usual events
377 | if (Clus.type(selector) === 'function') {
378 | handler = arguments[1];
379 | capture = arguments[2] || false;
380 | }
381 | for (j = 0; j < events.length; j++) {
382 | // check for namespaces
383 | if (events[j].indexOf('.') !== -1) {
384 | handleNamespaces(this[i], events[j], handler, capture);
385 | } else {
386 | this[i].addEventListener(events[j], handler, capture);
387 | }
388 | }
389 | } else {
390 | // Live events
391 | for (j = 0; j < events.length; j++) {
392 | if (!this[i].DomLiveListeners) {
393 | this[i].DomLiveListeners = [];
394 | }
395 |
396 | this[i].DomLiveListeners.push({
397 | handler: handler,
398 | liveListener: handleLiveEvent
399 | });
400 |
401 | if (events[j].indexOf('.') !== -1) {
402 | handleNamespaces(this[i], events[j], handleLiveEvent, capture);
403 | } else {
404 | this[i].addEventListener(events[j], handleLiveEvent, capture);
405 | }
406 | }
407 | }
408 | }
409 |
410 | function handleLiveEvent(event) {
411 | var k = void 0,
412 | parents = void 0,
413 | target = event.target;
414 |
415 | if (Clus(target).is(selector)) {
416 | handler.call(target, event);
417 | } else {
418 | parents = Clus(target).parents();
419 | for (k = 0; k < parents.length; k++) {
420 | if (Clus(parents[k]).is(selector)) {
421 | handler.call(parents[k], event);
422 | }
423 | }
424 | }
425 | }
426 |
427 | function handleNamespaces(elm, name, handler, capture) {
428 | var namespace = name.split('.');
429 |
430 | if (!elm.DomNameSpaces) {
431 | elm.DomNameSpaces = [];
432 | }
433 |
434 | elm.DomNameSpaces.push({
435 | namespace: namespace[1],
436 | event: namespace[0],
437 | handler: handler,
438 | capture: capture
439 | });
440 |
441 | elm.addEventListener(namespace[0], handler, capture);
442 | }
443 |
444 | return this;
445 | }
446 |
447 | function off(eventName, selector, handler, capture) {
448 | var events = void 0,
449 | i = void 0,
450 | j = void 0,
451 | k = void 0,
452 | that = this;
453 |
454 | events = eventName.split(' ');
455 |
456 | for (i = 0; i < events.length; i++) {
457 | for (j = 0; j < this.length; j++) {
458 | if (Clus.type(selector) === 'function' || selector === false) {
459 | // Usual events
460 | if (Clus.type(selector) === 'function') {
461 | handler = arguments[1];
462 | capture = arguments[2] || false;
463 | }
464 |
465 | if (events[i].indexOf('.') === 0) {
466 | // remove namespace events
467 | removeEvents(events[i].substr(1), handler, capture);
468 | } else {
469 | this[j].removeEventListener(events[i], handler, capture);
470 | }
471 | } else {
472 | // Live event
473 | if (this[j].DomLiveListeners) {
474 | for (k = 0; k < this[j].DomLiveListeners.length; k++) {
475 | if (this[j].DomLiveListeners[k].handler === handler) {
476 | this[j].removeEventListener(events[i], this[j].DomLiveListeners[k].liveListener, capture);
477 | }
478 | }
479 | }
480 | if (this[j].DomNameSpaces && this[j].DomNameSpaces.length && events[i]) {
481 | removeEvents(events[i]);
482 | }
483 | }
484 | }
485 | }
486 |
487 | function removeEvents(event) {
488 | var i = void 0,
489 | j = void 0,
490 | item = void 0,
491 | parts = event.split('.'),
492 | name = parts[0],
493 | ns = parts[1];
494 |
495 | for (i = 0; i < that.length; ++i) {
496 | if (that[i].DomNameSpaces) {
497 | for (j = 0; j < that[i].DomNameSpaces.length; ++j) {
498 | item = that[i].DomNameSpaces[j];
499 |
500 | if (item.namespace == ns && (item.event == name || !name)) {
501 | that[i].removeEventListener(item.event, item.handler, item.capture);
502 | item.removed = true;
503 | }
504 | }
505 | // remove the events from the DomNameSpaces array
506 | for (j = that[i].DomNameSpaces.length - 1; j >= 0; --j) {
507 | if (that[i].DomNameSpaces[j].removed) {
508 | that[i].DomNameSpaces.splice(j, 1);
509 | }
510 | }
511 | }
512 | }
513 | }
514 |
515 | return this;
516 | }
517 |
518 | function trigger(eventName, eventData) {
519 | var events = eventName.split(' '),
520 | i = 0,
521 | j = 0,
522 | evt = void 0;
523 | for (; i < events.length; i++) {
524 | for (; j < this.length; j++) {
525 | try {
526 | evt = new CustomEvent(events[i], {
527 | detail: eventData,
528 | bubbles: true,
529 | cancelable: true
530 | });
531 | } catch (e) {
532 | evt = document.createEvent('Event');
533 | evt.initEvent(events[i], true, true);
534 | evt.detail = eventData;
535 | }
536 | this[j].dispatchEvent(evt);
537 | }
538 | }
539 |
540 | return this;
541 | }
542 |
543 | Clus.fn.extend({
544 | on: on,
545 | off: off,
546 | trigger: trigger
547 | });
548 |
549 | //
550 | // dom search
551 | //
552 |
553 | function pushStack(els) {
554 | var ret = Clus.merge(this.contructor(), els);
555 | ret.prevObject = this;
556 | return ret;
557 | }
558 |
559 | function find(selector) {
560 | var i = 0,
561 | el = void 0,
562 | ret = this.pushStack([]);
563 |
564 | while (el = this[i++]) {
565 | ret = Clus.merge(ret, el.querySelectorAll(selector));
566 | }
567 |
568 | return ret;
569 | }
570 |
571 | function end() {
572 | return this.prevObject || this.contructor();
573 | }
574 |
575 | function eq(i) {
576 | var len = this.length,
577 | j = +i + (i < 0 ? len : 0); // reverse find
578 | return this.pushStack(j >= 0 && j < len ? [this[j]] : []);
579 | }
580 |
581 | function first() {
582 | return this.eq(0);
583 | }
584 |
585 | function last() {
586 | return this.eq(-1);
587 | }
588 |
589 | function parent(selector) {
590 | var parents = [],
591 | i = 0,
592 | len = this.length;
593 | for (; i < len; i++) {
594 | if (this[i].parentNode !== null) {
595 | if (selector) {
596 | if (Clus(this[i].parentNode).is(selector)) {
597 | parents.push(this[i].parentNode);
598 | }
599 | } else {
600 | parents.push(this[i].parentNode);
601 | }
602 | }
603 | }
604 | parents = Clus.unique(parents);
605 | return Clus(parents);
606 | }
607 |
608 | function parents(selector) {
609 | var parent = void 0,
610 | parents = [],
611 | i = 0,
612 | len = this.length;
613 | for (; i < len; i++) {
614 | parent = this[i].parentNode;
615 | while (parent) {
616 | if (selector) {
617 | if (Clus(parent).is(selector)) {
618 | parents.push(parent);
619 | }
620 | } else {
621 | parents.push(parent);
622 | }
623 | parent = parent.parentNode;
624 | }
625 | }
626 | parents = Clus.unique(parents);
627 | return Clus(parents);
628 | }
629 |
630 | function children(selector) {
631 | var children = [],
632 | childNodes = void 0,
633 | i = 0,
634 | j = 0,
635 | len = this.length;
636 | for (; i < len; i++) {
637 | childNodes = this[i].childNodes;
638 | for (; j < childNodes.length; j++) {
639 | if (!selector) {
640 | if (childNodes[j].nodeType === 1) {
641 | children.push(childNodes[j]);
642 | }
643 | } else {
644 | if (childNodes[j].nodeType === 1 && Clus(childNodes[j]).is(selector)) {
645 | children.push(childNodes[j]);
646 | }
647 | }
648 | }
649 | }
650 |
651 | return Clus(Clus.unique(children));
652 | }
653 |
654 | Clus.fn.extend({
655 | pushStack: pushStack,
656 | find: find,
657 | end: end,
658 | eq: eq,
659 | first: first,
660 | last: last,
661 | parent: parent,
662 | parents: parents,
663 | children: children
664 | });
665 |
666 | //
667 | // dom
668 | //
669 |
670 | var rnotwhite = /\S+/g;
671 | var rclass = /[\t\r\n\f]/g;
672 |
673 | function ready(callback) {
674 | if (document && /complete|loaded|interactive/.test(document.readyState) && document.body) {
675 | callback();
676 | } else {
677 | document.addEventListener('DOMContentLoaded', function () {
678 | callback();
679 | }, false);
680 | }
681 |
682 | return this;
683 | }
684 |
685 | function getClass(el) {
686 | return el.getAttribute && el.getAttribute('class') || '';
687 | }
688 |
689 | function addClass(cls) {
690 | var classes = void 0,
691 | clazz = void 0,
692 | el = void 0,
693 | cur = void 0,
694 | curValue = void 0,
695 | finalValue = void 0,
696 | j = void 0,
697 | i = 0;
698 |
699 | if (typeof cls === 'string' && cls) {
700 | classes = cls.match(rnotwhite) || [];
701 |
702 | while (el = this[i++]) {
703 | curValue = getClass(el);
704 | cur = el.nodeType === 1 && (' ' + curValue + ' ').replace(rclass, ' ');
705 |
706 | if (cur) {
707 | j = 0;
708 |
709 | while (clazz = classes[j++]) {
710 | // to determine whether the class that to add has already existed
711 | if (cur.indexOf(' ' + clazz + ' ') == -1) {
712 | cur += clazz + ' ';
713 | }
714 | finalValue = Clus.trim(cur);
715 | if (curValue !== finalValue) {
716 | el.setAttribute('class', finalValue);
717 | }
718 | }
719 | }
720 | }
721 | }
722 |
723 | return this;
724 | }
725 |
726 | function removeClass(cls) {
727 | var classes = void 0,
728 | clazz = void 0,
729 | el = void 0,
730 | cur = void 0,
731 | curValue = void 0,
732 | finalValue = void 0,
733 | j = void 0,
734 | i = 0;
735 |
736 | if (!arguments.length) {
737 | return;
738 | }
739 |
740 | if (typeof cls === 'string' && cls) {
741 | classes = cls.match(rnotwhite) || [];
742 |
743 | while (el = this[i++]) {
744 | curValue = getClass(el);
745 | cur = el.nodeType === 1 && (' ' + curValue + ' ').replace(rclass, ' ');
746 |
747 | if (cur) {
748 | j = 0;
749 |
750 | while (clazz = classes[j++]) {
751 | // to determine whether the class that to add has already existed
752 | if (cur.indexOf(' ' + clazz + ' ') !== -1) {
753 | cur = cur.replace(' ' + clazz + ' ', ' ');
754 | }
755 | finalValue = Clus.trim(cur);
756 | if (curValue !== finalValue) {
757 | el.setAttribute('class', finalValue);
758 | }
759 | }
760 | }
761 | }
762 | }
763 |
764 | return this;
765 | }
766 |
767 | function hasClass(cls) {
768 | var el = void 0,
769 | i = 0,
770 | className = ' ' + cls + ' ';
771 |
772 | while (el = this[i++]) {
773 | if (el.nodeType === 1 && (' ' + getClass(el) + ' ').replace(rclass, ' ').indexOf(className) !== -1) {
774 | return true;
775 | }
776 | }
777 |
778 | return false;
779 | }
780 |
781 | function toggleClass(cls) {
782 | var el = void 0,
783 | i = 0;
784 |
785 | while (el = this[i++]) {
786 | if (this.hasClass(cls)) {
787 | this.removeClass(cls);
788 | return this;
789 | } else {
790 | this.addClass(cls);
791 | return this;
792 | }
793 | }
794 | }
795 |
796 | function append(DOMString) {
797 | var el = void 0,
798 | i = 0,
799 | fregmentCollection = Clus.parseHTML(DOMString),
800 | fregments = Array.prototype.slice.apply(fregmentCollection);
801 |
802 | while (el = this[i++]) {
803 | fregments.map(function (fregment) {
804 | el.appendChild(fregment);
805 | });
806 | }
807 |
808 | return this;
809 | }
810 |
811 | function appendTo(selector) {
812 | var fregment = void 0,
813 | i = 0,
814 | elCollection = Clus.find(selector),
815 | els = Array.prototype.slice.apply(elCollection);
816 |
817 | while (fregment = this[i++]) {
818 | els.map(function (el) {
819 | el.appendChild(fregment);
820 | });
821 | }
822 | }
823 |
824 | function attr(attrs, value) {
825 | var attr = void 0,
826 | attrName = void 0,
827 | i = 0;
828 |
829 | if (arguments.length === 1 && typeof attrs === 'string' && this.length) {
830 | // get
831 | attr = this[0].getAttribute(attrs);
832 | return this[0] && (attr || attr === '') ? attr : undefined;
833 | } else {
834 | // set
835 | for (; i < this.length; i++) {
836 | if (arguments.length === 2) {
837 | // string
838 | this[i].setAttribute(attrs, value);
839 | } else {
840 | // object
841 | for (attrName in attrs) {
842 | this[i][attrName] = attrs[attrName];
843 | this[i].setAttribute(attrName, attrs[attrName]);
844 | }
845 | }
846 | }
847 |
848 | return this;
849 | }
850 | }
851 |
852 | function removeAttr(attr) {
853 | for (var i = 0; i < this.length; i++) {
854 | this[i].removeAttribute(attr);
855 | }
856 |
857 | return this;
858 | }
859 |
860 | Clus.fn.extend({
861 | ready: ready,
862 | addClass: addClass,
863 | removeClass: removeClass,
864 | hasClass: hasClass,
865 | toggleClass: toggleClass,
866 | append: append,
867 | appendTo: appendTo,
868 | attr: attr,
869 | removeAttr: removeAttr
870 | });
871 |
872 | //
873 | // ajax
874 | //
875 |
876 | /**
877 | * Initiate a Ajax request
878 | *
879 | * @method ajax
880 | * @param {Object} option
881 | */
882 | function ajax() {
883 | var option = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
884 |
885 | var xhr = new XMLHttpRequest(),
886 | type = option.type.toUpperCase() || 'GET',
887 | url = option.url || '',
888 | data = option.data,
889 | success = option.success || function success() {},
890 | error = option.error || function error() {},
891 | params = void 0;
892 |
893 | params = function (data) {
894 | var params = '',
895 | prop = void 0;
896 | for (prop in data) {
897 | if (data.hasOwnProperty(prop)) {
898 | params += prop + '=' + data[prop] + '&';
899 | }
900 | }
901 | params = params.slice(0, params.length - 1);
902 | return params;
903 | }(data);
904 |
905 | if (!url) console.error('url must be specified.');
906 |
907 | if (type === 'GET') url += url.indexOf('?') === -1 ? '?' + params : '&' + params;
908 |
909 | xhr.open(type, url);
910 |
911 | if (type === 'POST') xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
912 |
913 | xhr.send(params ? params : null);
914 |
915 | xhr.onload = function () {
916 | if (xhr.status === 200) {
917 | success(resToJson(xhr.response));
918 | } else {
919 | error(resToJson(xhr.response));
920 | }
921 | };
922 | }
923 |
924 | /**
925 | * Parse response to json
926 | *
927 | * @method resToJson
928 | * @param {String} response
929 | * @return {Object} object
930 | */
931 | function resToJson(response) {
932 | return JSON.parse(response);
933 | }
934 |
935 | Clus.extend({
936 | ajax: ajax
937 | });
938 |
939 | //
940 | // css
941 | //
942 |
943 | var humpRE = /\-(\w)/g;
944 |
945 | function humpize(rules) {
946 | return rules.replace(humpRE, function (_, letter) {
947 | return letter.toUpperCase();
948 | });
949 | }
950 |
951 | function css(rules, value) {
952 | var rule = void 0;
953 | if (Clus.type(rules) === 'string') {
954 | if (value === '' || Clus.type(value) === 'undefined' || Clus.type(value) === 'null') {
955 | return document.defaultView.getComputedStyle(this[0], null).getPropertyValue(rules);
956 | } else {
957 | this.each(function (el) {
958 | return el.style[humpize(rules)] = value;
959 | });
960 | }
961 | } else {
962 | for (rule in rules) {
963 | this.each(function (el) {
964 | return el.style[humpize(rule)] = rules[rule];
965 | });
966 | }
967 | }
968 | return this;
969 | }
970 |
971 | function width(width) {
972 | if (width !== undefined) {
973 | this.each(function (el) {
974 | el.style.width = width + 'px';
975 | });
976 | }
977 |
978 | var el = this[0];
979 |
980 | switch (el) {
981 | case window:
982 | {
983 | return window.innerWidth;
984 | }
985 | case document:
986 | {
987 | return document.documentElement.scrollWidth;
988 | }
989 | default:
990 | {
991 | return this.length > 0 ? parseFloat(this.css('width')) : null;
992 | }
993 | }
994 | }
995 |
996 | function height(height) {
997 | if (height !== undefined) {
998 | this.each(function (el) {
999 | el.style.height = height + 'px';
1000 | });
1001 | }
1002 |
1003 | var el = this[0];
1004 |
1005 | switch (el) {
1006 | case window:
1007 | {
1008 | return window.innerHeight;
1009 | }
1010 | case document:
1011 | {
1012 | var body = document.body,
1013 | html = document.documentElement,
1014 | heights = [body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight];
1015 |
1016 | return Math.max.apply(Math, heights);
1017 | }
1018 | default:
1019 | {
1020 | return this.length > 0 ? parseFloat(this.css('height')) : null;
1021 | }
1022 | }
1023 | }
1024 |
1025 | Clus.fn.extend({
1026 | css: css,
1027 | width: width,
1028 | height: height
1029 | });
1030 |
1031 | })));
1032 | //# sourceMappingURL=clus.js.map
1033 |
--------------------------------------------------------------------------------
/dist/clus.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":null,"sources":["../src/core/init.js","../src/core/extend.js","../src/core/core.js","../src/global.js","../src/instance.js","../src/event.js","../src/search.js","../src/dom.js","../src/ajax.js","../src/css.js"],"sourcesContent":["//\n// initialize\n//\n\n/**\n * Initialize\n *\n * @method init\n * @param {String} selector\n * @return {DOM} DOMList\n */\nexport default function init(selector) {\n let dom,\n fragmentRE = /^\\s*<(\\w+|!)[^>]*>/,\n selectorType = Clus.type(selector),\n elementTypes = [1, 9, 11];\n\n if (!selector) {\n dom = [],\n dom.selector = selector;\n } else if (elementTypes.indexOf(selector.nodeType) !== -1 || selector === window) {\n dom = [selector],\n selector = null;\n } else if (selectorType === 'function') {\n return Clus(document).ready(selector);\n } else if (selectorType === 'array') {\n dom = selector;\n } else if (selectorType === 'object') {\n dom = [selector],\n selector = null;\n } else if (selectorType === 'string') {\n if (selector[0] === '<' && fragmentRE.test(selector)) {\n dom = Clus.parseHTML(selector),\n selector = null;\n } else {\n dom = [].slice.call(document.querySelectorAll(selector));\n }\n }\n\n dom = dom || [];\n Clus.extend(dom, Clus.fn);\n dom.selector = selector;\n\n return dom;\n}\n","//\n// extend\n//\n\n/**\n * Extend object\n *\n * @method extend\n * @return {Object} object\n */\nexport default function extend() {\n let options, name, clone, copy, source, copyIsArray,\n target = arguments[0] || {},\n i = 1,\n length = arguments.length,\n deep = false;\n\n if (typeof target === 'boolean') {\n deep = target;\n target = arguments[i] || {};\n i++;\n }\n\n if (typeof target !== 'object' && Clus.type(target) !== 'function') {\n target = {};\n }\n\n if (i === length) {\n target = this;\n i--;\n }\n\n for (; i < length; i++) {\n //\n if ((options = arguments[i]) !== null) {\n // for in source object\n for (name in options) {\n\n source = target[name];\n copy = options[name];\n\n if (target == copy) {\n continue;\n }\n\n // deep clone\n if (deep && copy && (Clus.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {\n // if copy is array\n if (copyIsArray) {\n copyIsArray = false;\n // if is not array, set it to array\n clone = source && Array.isArray(source) ? source : [];\n } else {\n // if copy is not a object, set it to object\n clone = source && Clus.isPlainObject(source) ? source : {};\n }\n\n target[name] = extend(deep, clone, copy);\n } else if (copy !== undefined) {\n target[name] = copy;\n }\n }\n }\n }\n\n return target;\n}\n","//\n// core\n//\n\nimport init from './init';\nimport extend from './extend';\n\n/**\n * Constructor\n *\n * @constructor Clus\n * @method Clus\n * @param {String} selector\n */\nexport default function Clus (selector) {\n return new Clus.fn.init(selector);\n}\n\nClus.fn = Clus.prototype = {\n contructor: Clus,\n init,\n};\n\nClus.fn.init.prototype = Clus.fn;\n\nClus.extend = Clus.fn.extend = extend;\n\nwindow.Clus = window.C = window.$ = Clus;\n","//\n// global methods\n//\n\nexport function rootQuery(selector) {\n return document.querySelectorAll(selector);\n}\n\nexport function trim(text) {\n const rtrim = /^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g;\n return text == null ? '' : `${text}`.replace(rtrim, '');\n}\n\nexport function type(object) {\n let class2type = {},\n type = class2type.toString.call(object),\n typeString = 'Boolean Number String Function Array Date RegExp Object Error Symbol';\n\n if (object == null) {\n return object + '';\n }\n\n typeString.split(' ').forEach((type) => {\n class2type[`[object ${type}]`] = type.toLowerCase();\n });\n\n return (\n typeof object === 'object' ||\n typeof object === 'function'\n ?\n class2type[type] || 'object'\n :\n typeof object\n );\n}\n\nexport function isPlainObject(object) {\n let proto,\n ctor,\n class2type = {},\n toString = class2type.toString, // Object.prototype.toString\n hasOwn = class2type.hasOwnProperty,\n fnToString = hasOwn.toString, // Object.toString/Function.toString\n ObjectFunctionString = fnToString.call( Object ); // 'function Object() { [native code] }'\n\n if (!object || toString.call(object) !== '[object Object]') {\n return false;\n }\n\n // According to the object created by `Object.create(null)` is no `prototype`\n proto = Object.getPrototypeOf(object);\n if (!proto) {\n return true;\n }\n\n ctor = hasOwn.call(proto, 'constructor') && proto.constructor;\n return typeof ctor === 'function' && fnToString.call( ctor ) === ObjectFunctionString;\n}\n\nexport function isWindow(object) {\n return object !== null && object === object.window;\n}\n\nexport function isDocument(object) {\n return object !== null && object.nodeType == object.DOCUMENT_NODE;\n}\n\nexport function isArrayLike(object) {\n let len = !!object && 'length' in object && object.length,\n\t\ttype = Clus.type(object);\n\n\tif (type === 'function' || isWindow(object)) return false;\n\n\treturn type === 'array' || len === 0 || typeof length === 'number' && len > 0 && (len - 1) in object;\n}\n\nexport function flatten(array) {\n let ret = [],\n el,\n i = 0,\n len = array.length;\n\n for (; i < len; i++) {\n el = array[i];\n if (Array.isArray(el)) {\n ret.push.apply(ret, flatten(el));\n } else {\n ret.push(el);\n }\n }\n return ret;\n}\n\nexport function map(items, callback) {\n let value, values = [], len, i = 0;\n\n\tif (isArrayLike(items)) {\n\t\tlen = items.length;\n\t\tfor (; i < len; i++) {\n value = callback(items[i], i);\n if (value != null) values.push(value);\n\t\t}\n\t} else {\n\t\tfor (i in items) {\n value = callback(items[i], i);\n if (value != null) values.push(value);\n\t\t}\n\t}\n\n\treturn flatten(values);\n}\n\nexport function each(items, callback) {\n let len, i = 0;\n\n\tif ( isArrayLike(items) ) {\n\t\tlen = items.length;\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif (callback.call(items[i], items[i], i) === false) return items;\n\t\t}\n\t} else {\n\t\tfor ( i in items ) {\n if (callback.call(items[i], items[i], i) === false) return items;\n\t\t}\n\t}\n\n\treturn items;\n}\n\nexport function merge(first, second) {\n let len = +second.length,\n\t\tj = 0,\n\t\ti = first.length;\n\n\tfor ( ; j < len; j++ ) {\n\t\tfirst[ i++ ] = second[ j ];\n\t}\n\n\tfirst.length = i;\n\n\treturn first;\n}\n\nexport function unique(array) {\n let unique = [], i = 0, len = array.length;\n for (; i < len; i++) {\n if (unique.indexOf(array[i]) === -1) {\n unique.push(array[i]);\n }\n }\n return unique;\n}\n\nexport function matches(element, selector) {\n if (!selector || !element || element.nodeType !== 1) return false;\n\n let matchesSelector = element.matchesSelector || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector;\n\n return matchesSelector.call(element, selector);\n}\n\nexport function parseHTML(DOMString) {\n let htmlDoc = document.implementation.createHTMLDocument();\n htmlDoc.body.innerHTML = DOMString;\n return htmlDoc.body.children;\n}\n\nClus.extend({\n find: rootQuery,\n type,\n isPlainObject,\n isWindow,\n isDocument,\n isArrayLike,\n each,\n map,\n merge,\n trim,\n unique,\n matches,\n parseHTML,\n});\n","//\n// instance methods\n//\n\nfunction is(selector) {\n return this.length > 0 && Clus.matches(this[0], selector);\n}\n\nfunction instanceMap(callback) {\n return Clus(Clus.map(this, function(item, index) {\n return callback.call(item, item, index);\n }));\n}\n\nfunction instanceEach(callback) {\n [].every.call(this, function(item, index) {\n return callback.call(item, item, index) !== false;\n });\n return this;\n}\n\nClus.fn.extend({\n is,\n map: instanceMap,\n each: instanceEach,\n});\n","//\n// event\n//\n\nfunction on(eventName, selector, handler, capture) {\n let events = eventName.split(' '), i, j;\n\n for (i = 0; i < this.length; i++) {\n if (Clus.type(selector) === 'function' || selector === false) {\n // Usual events\n if (Clus.type(selector) === 'function') {\n handler = arguments[1];\n capture = arguments[2] || false;\n }\n for (j = 0; j < events.length; j++) {\n // check for namespaces\n if (events[j].indexOf('.') !== -1) {\n handleNamespaces(this[i], events[j], handler, capture);\n } else {\n this[i].addEventListener(events[j], handler, capture);\n }\n }\n } else {\n // Live events\n for (j = 0; j < events.length; j++) {\n if (!this[i].DomLiveListeners) {\n this[i].DomLiveListeners = [];\n }\n\n this[i].DomLiveListeners.push({\n handler: handler,\n liveListener: handleLiveEvent,\n });\n\n if (events[j].indexOf('.') !== -1) {\n handleNamespaces(this[i], events[j], handleLiveEvent, capture);\n } else {\n this[i].addEventListener(events[j], handleLiveEvent, capture);\n }\n }\n }\n }\n\n function handleLiveEvent(event) {\n let k,\n parents,\n target = event.target;\n\n if (Clus(target).is(selector)) {\n handler.call(target, event);\n } else {\n parents = Clus(target).parents();\n for (k = 0; k < parents.length; k++) {\n if (Clus(parents[k]).is(selector)) {\n handler.call(parents[k], event);\n }\n }\n }\n }\n\n function handleNamespaces(elm, name, handler, capture) {\n let namespace = name.split('.');\n\n if (!elm.DomNameSpaces) {\n elm.DomNameSpaces = [];\n }\n\n elm.DomNameSpaces.push({\n namespace: namespace[1],\n event: namespace[0],\n handler: handler,\n capture: capture,\n });\n\n elm.addEventListener(namespace[0], handler, capture);\n }\n\n return this;\n}\n\nfunction off(eventName, selector, handler, capture) {\n let events,\n i, j, k,\n that = this;\n\n events = eventName.split(' ');\n\n for (i = 0; i < events.length; i++) {\n for (j = 0; j < this.length; j++) {\n if (Clus.type(selector) === 'function' || selector === false) {\n // Usual events\n if (Clus.type(selector) === 'function') {\n handler = arguments[1];\n capture = arguments[2] || false;\n }\n\n if (events[i].indexOf('.') === 0) { // remove namespace events\n removeEvents(events[i].substr(1), handler, capture);\n } else {\n this[j].removeEventListener(events[i], handler, capture);\n }\n } else {\n // Live event\n if (this[j].DomLiveListeners) {\n for (k = 0; k < this[j].DomLiveListeners.length; k++) {\n if (this[j].DomLiveListeners[k].handler === handler) {\n this[j].removeEventListener(events[i], this[j].DomLiveListeners[k].liveListener, capture);\n }\n }\n }\n if (this[j].DomNameSpaces && this[j].DomNameSpaces.length && events[i]) {\n removeEvents(events[i]);\n }\n }\n }\n }\n\n function removeEvents(event) {\n let i, j,\n item,\n parts = event.split('.'),\n name = parts[0],\n ns = parts[1];\n\n for (i = 0; i < that.length; ++i) {\n if (that[i].DomNameSpaces) {\n for (j = 0; j < that[i].DomNameSpaces.length; ++j) {\n item = that[i].DomNameSpaces[j];\n\n if (item.namespace == ns && (item.event == name || !name)) {\n that[i].removeEventListener(item.event, item.handler, item.capture);\n item.removed = true;\n }\n }\n // remove the events from the DomNameSpaces array\n for (j = that[i].DomNameSpaces.length - 1; j >= 0; --j) {\n if (that[i].DomNameSpaces[j].removed) {\n that[i].DomNameSpaces.splice(j, 1);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction trigger(eventName, eventData) {\n let events = eventName.split(' '),\n i = 0,\n j = 0,\n evt;\n for (; i < events.length; i++) {\n for (; j < this.length; j++) {\n try {\n evt = new CustomEvent(events[i], {\n detail: eventData,\n bubbles: true,\n cancelable: true,\n });\n } catch (e) {\n evt = document.createEvent('Event');\n evt.initEvent(events[i], true, true);\n evt.detail = eventData;\n }\n this[j].dispatchEvent(evt);\n }\n }\n\n return this;\n}\n\nClus.fn.extend({\n on,\n off,\n trigger,\n});\n","//\n// dom search\n//\n\nfunction pushStack(els) {\n let ret = Clus.merge(this.contructor(), els);\n ret.prevObject = this;\n return ret;\n}\n\nfunction find(selector) {\n let i = 0,\n el,\n ret = this.pushStack([]);\n\n while((el = this[i++])) {\n ret = Clus.merge(ret, el.querySelectorAll(selector));\n }\n\n return ret;\n}\n\nfunction end() {\n return this.prevObject || this.contructor();\n}\n\nfunction eq(i) {\n let len = this.length,\n j = +i + ( i < 0 ? len : 0 ); // reverse find\n return this.pushStack(j >= 0 && j < len ? [this[j]] : []);\n}\n\nfunction first() {\n return this.eq(0);\n}\n\nfunction last() {\n return this.eq(-1);\n}\n\nfunction parent(selector) {\n let parents = [], i = 0, len = this.length;\n for (; i < len; i++) {\n if (this[i].parentNode !== null) {\n if (selector) {\n if (Clus(this[i].parentNode).is(selector)) {\n parents.push(this[i].parentNode);\n }\n } else {\n parents.push(this[i].parentNode);\n }\n }\n }\n parents = Clus.unique(parents);\n return Clus(parents);\n}\n\nfunction parents(selector) {\n let parent, parents = [], i = 0, len = this.length;\n for (; i < len; i++) {\n parent = this[i].parentNode;\n while (parent) {\n if (selector) {\n if (Clus(parent).is(selector)) {\n parents.push(parent);\n }\n } else {\n parents.push(parent);\n }\n parent = parent.parentNode;\n }\n }\n parents = Clus.unique(parents);\n return Clus(parents);\n}\n\nfunction children(selector) {\n let children = [], childNodes, i = 0, j = 0, len = this.length;\n for (; i < len; i++) {\n childNodes = this[i].childNodes;\n for (; j < childNodes.length; j++) {\n if (!selector) {\n if (childNodes[j].nodeType === 1) {\n children.push(childNodes[j]);\n }\n } else {\n if (childNodes[j].nodeType === 1 && Clus(childNodes[j]).is(selector)) {\n children.push(childNodes[j]);\n }\n }\n }\n }\n\n return Clus(Clus.unique(children));\n}\n\nClus.fn.extend({\n pushStack,\n find,\n end,\n eq,\n first,\n last,\n parent,\n parents,\n children,\n});\n","//\n// dom\n//\n\nconst rnotwhite = /\\S+/g;\nconst rclass = /[\\t\\r\\n\\f]/g;\n\nfunction ready(callback) {\n if (\n document\n &&\n /complete|loaded|interactive/.test(document.readyState)\n &&\n document.body\n ) {\n callback();\n } else {\n document.addEventListener('DOMContentLoaded', function () {\n callback();\n }, false);\n }\n\n return this;\n}\n\nfunction getClass(el) {\n return el.getAttribute && el.getAttribute('class') || '';\n}\n\nfunction addClass(cls) {\n let classes, clazz, el, cur, curValue, finalValue, j, i = 0;\n\n if (typeof cls === 'string' && cls) {\n classes = cls.match(rnotwhite) || [];\n\n while((el = this[i++])) {\n curValue = getClass(el);\n cur = (el.nodeType === 1) && ` ${curValue} `.replace(rclass, ' ');\n\n if (cur) {\n j = 0;\n\n while((clazz = classes[j++])) {\n // to determine whether the class that to add has already existed\n if (cur.indexOf(` ${clazz} `) == -1) {\n cur += clazz + ' ';\n }\n finalValue = Clus.trim(cur);\n if ( curValue !== finalValue ) {\n el.setAttribute('class', finalValue);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction removeClass(cls) {\n let classes, clazz, el, cur, curValue, finalValue, j, i = 0;\n\n if (!arguments.length) {\n return;\n }\n\n if (typeof cls === 'string' && cls) {\n classes = cls.match(rnotwhite) || [];\n\n while((el = this[i++])) {\n curValue = getClass(el);\n cur = (el.nodeType === 1) && ` ${curValue} `.replace(rclass, ' ');\n\n if (cur) {\n j = 0;\n\n while((clazz = classes[j++])) {\n // to determine whether the class that to add has already existed\n if (cur.indexOf(` ${clazz} `) !== -1) {\n cur = cur.replace(` ${clazz} `, ' ');\n }\n finalValue = Clus.trim(cur);\n if ( curValue !== finalValue ) {\n el.setAttribute('class', finalValue);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction hasClass(cls) {\n let el, i = 0, className = ` ${cls} `;\n\n while((el = this[i++])) {\n if (\n el.nodeType === 1\n &&\n ` ${getClass(el)} `.replace(rclass, ' ').indexOf(className) !== -1\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction toggleClass(cls) {\n let el, i = 0;\n\n while((el = this[i++])) {\n if (this.hasClass(cls)) {\n this.removeClass(cls);\n return this;\n } else {\n this.addClass(cls);\n return this;\n }\n }\n}\n\nfunction append(DOMString) {\n let el, i = 0,\n fregmentCollection = Clus.parseHTML(DOMString),\n fregments = Array.prototype.slice.apply(fregmentCollection);\n\n while((el = this[i++])) {\n fregments.map(fregment => {\n el.appendChild(fregment);\n });\n }\n\n return this;\n}\n\nfunction appendTo(selector) {\n let fregment, i = 0,\n elCollection = Clus.find(selector),\n els = Array.prototype.slice.apply(elCollection);\n\n while((fregment = this[i++])) {\n els.map(el => {\n el.appendChild(fregment);\n });\n }\n}\n\nfunction attr(attrs, value) {\n let attr, attrName, i = 0;\n\n if (arguments.length === 1 && typeof attrs === 'string' && this.length) {\n // get\n attr = this[0].getAttribute(attrs);\n return this[0] && (attr || attr === '') ? attr : undefined;\n } else {\n // set\n for (; i < this.length; i++) {\n if (arguments.length === 2) {\n // string\n this[i].setAttribute(attrs, value);\n } else {\n // object\n for (attrName in attrs) {\n this[i][attrName] = attrs[attrName];\n this[i].setAttribute(attrName, attrs[attrName]);\n }\n }\n }\n\n return this;\n }\n}\n\nfunction removeAttr(attr) {\n for (let i = 0; i < this.length; i++) {\n this[i].removeAttribute(attr);\n }\n\n return this;\n}\n\nClus.fn.extend({\n ready,\n addClass,\n removeClass,\n hasClass,\n toggleClass,\n append,\n appendTo,\n attr,\n removeAttr,\n});\n","//\n// ajax\n//\n\n/**\n * Initiate a Ajax request\n *\n * @method ajax\n * @param {Object} option\n */\nfunction ajax(option = {}) {\n let xhr = new XMLHttpRequest(),\n type = option.type.toUpperCase() || 'GET',\n url = option.url || '',\n data = option.data,\n success = option.success || function success() {},\n error = option.error || function error() {},\n params;\n\n params = (function (data) {\n let params = '', prop;\n for (prop in data) {\n if (data.hasOwnProperty(prop)) {\n params += prop + '=' + data[prop] + '&';\n }\n }\n params = params.slice(0, params.length - 1);\n return params;\n })(data);\n\n if (!url) console.error('url must be specified.');\n\n if (type === 'GET') url += url.indexOf('?') === -1 ? '?' + params : '&' + params;\n\n xhr.open(type, url);\n\n if (type === 'POST') xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n\n xhr.send(params ? params : null);\n\n xhr.onload = function () {\n if (xhr.status === 200) {\n success(resToJson(xhr.response));\n } else {\n error(resToJson(xhr.response));\n }\n };\n}\n\n/**\n * Parse response to json\n *\n * @method resToJson\n * @param {String} response\n * @return {Object} object\n */\nfunction resToJson(response) {\n return JSON.parse(response);\n}\n\nClus.extend({\n ajax,\n});\n","//\n// css\n//\n\nconst humpRE = /\\-(\\w)/g;\n\nfunction humpize(rules) {\n return rules.replace(humpRE, (_, letter) => letter.toUpperCase());\n}\n\nfunction css(rules, value) {\n let rule;\n if (Clus.type(rules) === 'string') {\n if (value === '' || Clus.type(value) === 'undefined' || Clus.type(value) === 'null') {\n return document.defaultView.getComputedStyle(this[0], null).getPropertyValue(rules);\n } else {\n this.each(el => el.style[humpize(rules)] = value);\n }\n } else {\n for (rule in rules) {\n this.each(el => el.style[humpize(rule)] = rules[rule]);\n }\n }\n return this;\n}\n\nfunction width(width) {\n if (width !== undefined) {\n this.each(el => {\n el.style.width = `${width}px`;\n });\n }\n\n let el = this[0];\n\n switch (el) {\n case window: {\n return window.innerWidth;\n }\n case document: {\n return document.documentElement.scrollWidth;\n }\n default: {\n return this.length > 0 ? parseFloat(this.css('width')) : null;\n }\n }\n}\n\nfunction height(height) {\n if (height !== undefined) {\n this.each(el => {\n el.style.height = `${height}px`;\n });\n }\n\n let el = this[0];\n\n switch (el) {\n case window: {\n return window.innerHeight;\n }\n case document: {\n let body = document.body,\n html = document.documentElement,\n heights = [body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight];\n\n return Math.max.apply(Math, heights);\n }\n default: {\n return this.length > 0 ? parseFloat(this.css('height')) : null;\n }\n }\n}\n\nClus.fn.extend({\n css,\n width,\n height,\n});\n"],"names":["Clus"],"mappings":";;;;;;AAAA;;;;;;;;;;;AAWA,AAAe,SAAS,IAAT,CAAc,QAAd,EAAwB;QAC/B,YAAJ;QACI,aAAa,oBADjB;QAEI,eAAe,KAAK,IAAL,CAAU,QAAV,CAFnB;QAGI,eAAe,CAAC,CAAD,EAAI,CAAJ,EAAO,EAAP,CAHnB;;QAKI,CAAC,QAAL,EAAe;cACL,EAAN,E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A0B;aACjB,IAAL,CAAU,cAAM;eACT,KAAH,CAAS,MAAT,GAAqB,MAArB;SADJ;;;QAKA,KAAK,KAAK,CAAL,CAAT;;YAEQ,EAAR;aACS,MAAL;;uBACW,OAAO,WAAd;;aAEC,QAAL;;oBACQ,OAAO,SAAS,IAApB;oBACI,OAAO,SAAS,eADpB;oBAEI,UAAU,CAAC,KAAK,YAAN,EAAoB,KAAK,YAAzB,EAAuC,KAAK,YAA5C,EAA0D,KAAK,YAA/D,EAA6E,KAAK,YAAlF,CAFd;;uBAIO,KAAK,GAAL,CAAS,KAAT,CAAe,IAAf,EAAqB,OAArB,CAAP;;;;uBAGO,KAAK,MAAL,GAAc,CAAd,GAAkB,WAAW,KAAK,GAAL,CAAS,QAAT,CAAX,CAAlB,GAAmD,IAA1D;;;;;AAKZ,KAAK,EAAL,CAAQ,MAAR,CAAe;YAAA;gBAAA;;CAAf;;"}
--------------------------------------------------------------------------------
/dist/clus.min.js:
--------------------------------------------------------------------------------
1 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define("Clus",t):t()}(this,function(){"use strict";function e(e){var t=void 0,n=/^\s*<(\w+|!)[^>]*>/,i=Clus.type(e),r=[1,9,11];if(e)if(r.indexOf(e.nodeType)!==-1||e===window)t=[e],e=null;else{if("function"===i)return Clus(document).ready(e);"array"===i?t=e:"object"===i?(t=[e],e=null):"string"===i&&("<"===e[0]&&n.test(e)?(t=Clus.parseHTML(e),e=null):t=[].slice.call(document.querySelectorAll(e)))}else t=[],t.selector=e;return t=t||[],Clus.extend(t,Clus.fn),t.selector=e,t}function t(){var e=void 0,n=void 0,i=void 0,r=void 0,o=void 0,s=void 0,u=arguments[0]||{},l=1,c=arguments.length,a=!1;for("boolean"==typeof u&&(a=u,u=arguments[l]||{},l++),"object"!==("undefined"==typeof u?"undefined":_(u))&&"function"!==Clus.type(u)&&(u={}),l===c&&(u=this,l--);l0&&t-1 in e)}function a(e){for(var t=[],n=void 0,i=0,r=e.length;i0&&Clus.matches(this[0],e)}function g(e){return Clus(Clus.map(this,function(t,n){return e.call(t,t,n)}))}function C(e){return[].every.call(this,function(t,n){return e.call(t,t,n)!==!1}),this}function b(e,t,n,i){function r(e){var i=void 0,r=void 0,o=e.target;if(Clus(o).is(t))n.call(o,e);else for(r=Clus(o).parents(),i=0;i=0;--n)c[t].DomNameSpaces[n].removed&&c[t].DomNameSpaces.splice(n,1)}}var o=void 0,s=void 0,u=void 0,l=void 0,c=this;for(o=e.split(" "),s=0;s=0&&n0?parseFloat(this.css("width")):null}}function X(e){void 0!==e&&this.each(function(t){t.style.height=e+"px"});var t=this[0];switch(t){case window:return window.innerHeight;case document:var n=document.body,i=document.documentElement,r=[n.scrollHeight,n.offsetHeight,i.clientHeight,i.scrollHeight,i.offsetHeight];return Math.max.apply(Math,r);default:return this.length>0?parseFloat(this.css("height")):null}}var _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};n.fn=n.prototype={contructor:n,init:e},n.fn.init.prototype=n.fn,n.extend=n.fn.extend=t,window.Clus=window.C=window.$=n,Clus.extend({find:i,type:o,isPlainObject:s,isWindow:u,isDocument:l,isArrayLike:c,each:d,map:f,merge:h,trim:r,unique:p,matches:v,parseHTML:m}),Clus.fn.extend({is:y,map:g,each:C}),Clus.fn.extend({on:b,off:w,trigger:S}),Clus.fn.extend({pushStack:L,find:x,end:O,eq:A,first:D,last:E,parent:N,parents:T,children:j});var I=/\S+/g,K=/[\t\r\n\f]/g;Clus.fn.extend({ready:H,addClass:q,removeClass:F,hasClass:P,toggleClass:k,append:R,appendTo:U,attr:W,removeAttr:G}),Clus.extend({ajax:V});var Q=/\-(\w)/g;Clus.fn.extend({css:B,width:J,height:X})});
2 | //# sourceMappingURL=clus.min.js.map
3 |
--------------------------------------------------------------------------------
/dist/clus.min.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":null,"sources":["../src/core/init.js","../src/core/extend.js","../src/core/core.js","../src/global.js","../src/instance.js","../src/event.js","../src/search.js","../src/dom.js","../src/ajax.js","../src/css.js"],"sourcesContent":["//\n// initialize\n//\n\n/**\n * Initialize\n *\n * @method init\n * @param {String} selector\n * @return {DOM} DOMList\n */\nexport default function init(selector) {\n let dom,\n fragmentRE = /^\\s*<(\\w+|!)[^>]*>/,\n selectorType = Clus.type(selector),\n elementTypes = [1, 9, 11];\n\n if (!selector) {\n dom = [],\n dom.selector = selector;\n } else if (elementTypes.indexOf(selector.nodeType) !== -1 || selector === window) {\n dom = [selector],\n selector = null;\n } else if (selectorType === 'function') {\n return Clus(document).ready(selector);\n } else if (selectorType === 'array') {\n dom = selector;\n } else if (selectorType === 'object') {\n dom = [selector],\n selector = null;\n } else if (selectorType === 'string') {\n if (selector[0] === '<' && fragmentRE.test(selector)) {\n dom = Clus.parseHTML(selector),\n selector = null;\n } else {\n dom = [].slice.call(document.querySelectorAll(selector));\n }\n }\n\n dom = dom || [];\n Clus.extend(dom, Clus.fn);\n dom.selector = selector;\n\n return dom;\n}\n","//\n// extend\n//\n\n/**\n * Extend object\n *\n * @method extend\n * @return {Object} object\n */\nexport default function extend() {\n let options, name, clone, copy, source, copyIsArray,\n target = arguments[0] || {},\n i = 1,\n length = arguments.length,\n deep = false;\n\n if (typeof target === 'boolean') {\n deep = target;\n target = arguments[i] || {};\n i++;\n }\n\n if (typeof target !== 'object' && Clus.type(target) !== 'function') {\n target = {};\n }\n\n if (i === length) {\n target = this;\n i--;\n }\n\n for (; i < length; i++) {\n //\n if ((options = arguments[i]) !== null) {\n // for in source object\n for (name in options) {\n\n source = target[name];\n copy = options[name];\n\n if (target == copy) {\n continue;\n }\n\n // deep clone\n if (deep && copy && (Clus.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {\n // if copy is array\n if (copyIsArray) {\n copyIsArray = false;\n // if is not array, set it to array\n clone = source && Array.isArray(source) ? source : [];\n } else {\n // if copy is not a object, set it to object\n clone = source && Clus.isPlainObject(source) ? source : {};\n }\n\n target[name] = extend(deep, clone, copy);\n } else if (copy !== undefined) {\n target[name] = copy;\n }\n }\n }\n }\n\n return target;\n}\n","//\n// core\n//\n\nimport init from './init';\nimport extend from './extend';\n\n/**\n * Constructor\n *\n * @constructor Clus\n * @method Clus\n * @param {String} selector\n */\nexport default function Clus (selector) {\n return new Clus.fn.init(selector);\n}\n\nClus.fn = Clus.prototype = {\n contructor: Clus,\n init,\n};\n\nClus.fn.init.prototype = Clus.fn;\n\nClus.extend = Clus.fn.extend = extend;\n\nwindow.Clus = window.C = window.$ = Clus;\n","//\n// global methods\n//\n\nexport function rootQuery(selector) {\n return document.querySelectorAll(selector);\n}\n\nexport function trim(text) {\n const rtrim = /^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g;\n return text == null ? '' : `${text}`.replace(rtrim, '');\n}\n\nexport function type(object) {\n let class2type = {},\n type = class2type.toString.call(object),\n typeString = 'Boolean Number String Function Array Date RegExp Object Error Symbol';\n\n if (object == null) {\n return object + '';\n }\n\n typeString.split(' ').forEach((type) => {\n class2type[`[object ${type}]`] = type.toLowerCase();\n });\n\n return (\n typeof object === 'object' ||\n typeof object === 'function'\n ?\n class2type[type] || 'object'\n :\n typeof object\n );\n}\n\nexport function isPlainObject(object) {\n let proto,\n ctor,\n class2type = {},\n toString = class2type.toString, // Object.prototype.toString\n hasOwn = class2type.hasOwnProperty,\n fnToString = hasOwn.toString, // Object.toString/Function.toString\n ObjectFunctionString = fnToString.call( Object ); // 'function Object() { [native code] }'\n\n if (!object || toString.call(object) !== '[object Object]') {\n return false;\n }\n\n // According to the object created by `Object.create(null)` is no `prototype`\n proto = Object.getPrototypeOf(object);\n if (!proto) {\n return true;\n }\n\n ctor = hasOwn.call(proto, 'constructor') && proto.constructor;\n return typeof ctor === 'function' && fnToString.call( ctor ) === ObjectFunctionString;\n}\n\nexport function isWindow(object) {\n return object !== null && object === object.window;\n}\n\nexport function isDocument(object) {\n return object !== null && object.nodeType == object.DOCUMENT_NODE;\n}\n\nexport function isArrayLike(object) {\n let len = !!object && 'length' in object && object.length,\n\t\ttype = Clus.type(object);\n\n\tif (type === 'function' || isWindow(object)) return false;\n\n\treturn type === 'array' || len === 0 || typeof length === 'number' && len > 0 && (len - 1) in object;\n}\n\nexport function flatten(array) {\n let ret = [],\n el,\n i = 0,\n len = array.length;\n\n for (; i < len; i++) {\n el = array[i];\n if (Array.isArray(el)) {\n ret.push.apply(ret, flatten(el));\n } else {\n ret.push(el);\n }\n }\n return ret;\n}\n\nexport function map(items, callback) {\n let value, values = [], len, i = 0;\n\n\tif (isArrayLike(items)) {\n\t\tlen = items.length;\n\t\tfor (; i < len; i++) {\n value = callback(items[i], i);\n if (value != null) values.push(value);\n\t\t}\n\t} else {\n\t\tfor (i in items) {\n value = callback(items[i], i);\n if (value != null) values.push(value);\n\t\t}\n\t}\n\n\treturn flatten(values);\n}\n\nexport function each(items, callback) {\n let len, i = 0;\n\n\tif ( isArrayLike(items) ) {\n\t\tlen = items.length;\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif (callback.call(items[i], items[i], i) === false) return items;\n\t\t}\n\t} else {\n\t\tfor ( i in items ) {\n if (callback.call(items[i], items[i], i) === false) return items;\n\t\t}\n\t}\n\n\treturn items;\n}\n\nexport function merge(first, second) {\n let len = +second.length,\n\t\tj = 0,\n\t\ti = first.length;\n\n\tfor ( ; j < len; j++ ) {\n\t\tfirst[ i++ ] = second[ j ];\n\t}\n\n\tfirst.length = i;\n\n\treturn first;\n}\n\nexport function unique(array) {\n let unique = [], i = 0, len = array.length;\n for (; i < len; i++) {\n if (unique.indexOf(array[i]) === -1) {\n unique.push(array[i]);\n }\n }\n return unique;\n}\n\nexport function matches(element, selector) {\n if (!selector || !element || element.nodeType !== 1) return false;\n\n let matchesSelector = element.matchesSelector || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector;\n\n return matchesSelector.call(element, selector);\n}\n\nexport function parseHTML(DOMString) {\n let htmlDoc = document.implementation.createHTMLDocument();\n htmlDoc.body.innerHTML = DOMString;\n return htmlDoc.body.children;\n}\n\nClus.extend({\n find: rootQuery,\n type,\n isPlainObject,\n isWindow,\n isDocument,\n isArrayLike,\n each,\n map,\n merge,\n trim,\n unique,\n matches,\n parseHTML,\n});\n","//\n// instance methods\n//\n\nfunction is(selector) {\n return this.length > 0 && Clus.matches(this[0], selector);\n}\n\nfunction instanceMap(callback) {\n return Clus(Clus.map(this, function(item, index) {\n return callback.call(item, item, index);\n }));\n}\n\nfunction instanceEach(callback) {\n [].every.call(this, function(item, index) {\n return callback.call(item, item, index) !== false;\n });\n return this;\n}\n\nClus.fn.extend({\n is,\n map: instanceMap,\n each: instanceEach,\n});\n","//\n// event\n//\n\nfunction on(eventName, selector, handler, capture) {\n let events = eventName.split(' '), i, j;\n\n for (i = 0; i < this.length; i++) {\n if (Clus.type(selector) === 'function' || selector === false) {\n // Usual events\n if (Clus.type(selector) === 'function') {\n handler = arguments[1];\n capture = arguments[2] || false;\n }\n for (j = 0; j < events.length; j++) {\n // check for namespaces\n if (events[j].indexOf('.') !== -1) {\n handleNamespaces(this[i], events[j], handler, capture);\n } else {\n this[i].addEventListener(events[j], handler, capture);\n }\n }\n } else {\n // Live events\n for (j = 0; j < events.length; j++) {\n if (!this[i].DomLiveListeners) {\n this[i].DomLiveListeners = [];\n }\n\n this[i].DomLiveListeners.push({\n handler: handler,\n liveListener: handleLiveEvent,\n });\n\n if (events[j].indexOf('.') !== -1) {\n handleNamespaces(this[i], events[j], handleLiveEvent, capture);\n } else {\n this[i].addEventListener(events[j], handleLiveEvent, capture);\n }\n }\n }\n }\n\n function handleLiveEvent(event) {\n let k,\n parents,\n target = event.target;\n\n if (Clus(target).is(selector)) {\n handler.call(target, event);\n } else {\n parents = Clus(target).parents();\n for (k = 0; k < parents.length; k++) {\n if (Clus(parents[k]).is(selector)) {\n handler.call(parents[k], event);\n }\n }\n }\n }\n\n function handleNamespaces(elm, name, handler, capture) {\n let namespace = name.split('.');\n\n if (!elm.DomNameSpaces) {\n elm.DomNameSpaces = [];\n }\n\n elm.DomNameSpaces.push({\n namespace: namespace[1],\n event: namespace[0],\n handler: handler,\n capture: capture,\n });\n\n elm.addEventListener(namespace[0], handler, capture);\n }\n\n return this;\n}\n\nfunction off(eventName, selector, handler, capture) {\n let events,\n i, j, k,\n that = this;\n\n events = eventName.split(' ');\n\n for (i = 0; i < events.length; i++) {\n for (j = 0; j < this.length; j++) {\n if (Clus.type(selector) === 'function' || selector === false) {\n // Usual events\n if (Clus.type(selector) === 'function') {\n handler = arguments[1];\n capture = arguments[2] || false;\n }\n\n if (events[i].indexOf('.') === 0) { // remove namespace events\n removeEvents(events[i].substr(1), handler, capture);\n } else {\n this[j].removeEventListener(events[i], handler, capture);\n }\n } else {\n // Live event\n if (this[j].DomLiveListeners) {\n for (k = 0; k < this[j].DomLiveListeners.length; k++) {\n if (this[j].DomLiveListeners[k].handler === handler) {\n this[j].removeEventListener(events[i], this[j].DomLiveListeners[k].liveListener, capture);\n }\n }\n }\n if (this[j].DomNameSpaces && this[j].DomNameSpaces.length && events[i]) {\n removeEvents(events[i]);\n }\n }\n }\n }\n\n function removeEvents(event) {\n let i, j,\n item,\n parts = event.split('.'),\n name = parts[0],\n ns = parts[1];\n\n for (i = 0; i < that.length; ++i) {\n if (that[i].DomNameSpaces) {\n for (j = 0; j < that[i].DomNameSpaces.length; ++j) {\n item = that[i].DomNameSpaces[j];\n\n if (item.namespace == ns && (item.event == name || !name)) {\n that[i].removeEventListener(item.event, item.handler, item.capture);\n item.removed = true;\n }\n }\n // remove the events from the DomNameSpaces array\n for (j = that[i].DomNameSpaces.length - 1; j >= 0; --j) {\n if (that[i].DomNameSpaces[j].removed) {\n that[i].DomNameSpaces.splice(j, 1);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction trigger(eventName, eventData) {\n let events = eventName.split(' '),\n i = 0,\n j = 0,\n evt;\n for (; i < events.length; i++) {\n for (; j < this.length; j++) {\n try {\n evt = new CustomEvent(events[i], {\n detail: eventData,\n bubbles: true,\n cancelable: true,\n });\n } catch (e) {\n evt = document.createEvent('Event');\n evt.initEvent(events[i], true, true);\n evt.detail = eventData;\n }\n this[j].dispatchEvent(evt);\n }\n }\n\n return this;\n}\n\nClus.fn.extend({\n on,\n off,\n trigger,\n});\n","//\n// dom search\n//\n\nfunction pushStack(els) {\n let ret = Clus.merge(this.contructor(), els);\n ret.prevObject = this;\n return ret;\n}\n\nfunction find(selector) {\n let i = 0,\n el,\n ret = this.pushStack([]);\n\n while((el = this[i++])) {\n ret = Clus.merge(ret, el.querySelectorAll(selector));\n }\n\n return ret;\n}\n\nfunction end() {\n return this.prevObject || this.contructor();\n}\n\nfunction eq(i) {\n let len = this.length,\n j = +i + ( i < 0 ? len : 0 ); // reverse find\n return this.pushStack(j >= 0 && j < len ? [this[j]] : []);\n}\n\nfunction first() {\n return this.eq(0);\n}\n\nfunction last() {\n return this.eq(-1);\n}\n\nfunction parent(selector) {\n let parents = [], i = 0, len = this.length;\n for (; i < len; i++) {\n if (this[i].parentNode !== null) {\n if (selector) {\n if (Clus(this[i].parentNode).is(selector)) {\n parents.push(this[i].parentNode);\n }\n } else {\n parents.push(this[i].parentNode);\n }\n }\n }\n parents = Clus.unique(parents);\n return Clus(parents);\n}\n\nfunction parents(selector) {\n let parent, parents = [], i = 0, len = this.length;\n for (; i < len; i++) {\n parent = this[i].parentNode;\n while (parent) {\n if (selector) {\n if (Clus(parent).is(selector)) {\n parents.push(parent);\n }\n } else {\n parents.push(parent);\n }\n parent = parent.parentNode;\n }\n }\n parents = Clus.unique(parents);\n return Clus(parents);\n}\n\nfunction children(selector) {\n let children = [], childNodes, i = 0, j = 0, len = this.length;\n for (; i < len; i++) {\n childNodes = this[i].childNodes;\n for (; j < childNodes.length; j++) {\n if (!selector) {\n if (childNodes[j].nodeType === 1) {\n children.push(childNodes[j]);\n }\n } else {\n if (childNodes[j].nodeType === 1 && Clus(childNodes[j]).is(selector)) {\n children.push(childNodes[j]);\n }\n }\n }\n }\n\n return Clus(Clus.unique(children));\n}\n\nClus.fn.extend({\n pushStack,\n find,\n end,\n eq,\n first,\n last,\n parent,\n parents,\n children,\n});\n","//\n// dom\n//\n\nconst rnotwhite = /\\S+/g;\nconst rclass = /[\\t\\r\\n\\f]/g;\n\nfunction ready(callback) {\n if (\n document\n &&\n /complete|loaded|interactive/.test(document.readyState)\n &&\n document.body\n ) {\n callback();\n } else {\n document.addEventListener('DOMContentLoaded', function () {\n callback();\n }, false);\n }\n\n return this;\n}\n\nfunction getClass(el) {\n return el.getAttribute && el.getAttribute('class') || '';\n}\n\nfunction addClass(cls) {\n let classes, clazz, el, cur, curValue, finalValue, j, i = 0;\n\n if (typeof cls === 'string' && cls) {\n classes = cls.match(rnotwhite) || [];\n\n while((el = this[i++])) {\n curValue = getClass(el);\n cur = (el.nodeType === 1) && ` ${curValue} `.replace(rclass, ' ');\n\n if (cur) {\n j = 0;\n\n while((clazz = classes[j++])) {\n // to determine whether the class that to add has already existed\n if (cur.indexOf(` ${clazz} `) == -1) {\n cur += clazz + ' ';\n }\n finalValue = Clus.trim(cur);\n if ( curValue !== finalValue ) {\n el.setAttribute('class', finalValue);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction removeClass(cls) {\n let classes, clazz, el, cur, curValue, finalValue, j, i = 0;\n\n if (!arguments.length) {\n return;\n }\n\n if (typeof cls === 'string' && cls) {\n classes = cls.match(rnotwhite) || [];\n\n while((el = this[i++])) {\n curValue = getClass(el);\n cur = (el.nodeType === 1) && ` ${curValue} `.replace(rclass, ' ');\n\n if (cur) {\n j = 0;\n\n while((clazz = classes[j++])) {\n // to determine whether the class that to add has already existed\n if (cur.indexOf(` ${clazz} `) !== -1) {\n cur = cur.replace(` ${clazz} `, ' ');\n }\n finalValue = Clus.trim(cur);\n if ( curValue !== finalValue ) {\n el.setAttribute('class', finalValue);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction hasClass(cls) {\n let el, i = 0, className = ` ${cls} `;\n\n while((el = this[i++])) {\n if (\n el.nodeType === 1\n &&\n ` ${getClass(el)} `.replace(rclass, ' ').indexOf(className) !== -1\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction toggleClass(cls) {\n let el, i = 0;\n\n while((el = this[i++])) {\n if (this.hasClass(cls)) {\n this.removeClass(cls);\n return this;\n } else {\n this.addClass(cls);\n return this;\n }\n }\n}\n\nfunction append(DOMString) {\n let el, i = 0,\n fregmentCollection = Clus.parseHTML(DOMString),\n fregments = Array.prototype.slice.apply(fregmentCollection);\n\n while((el = this[i++])) {\n fregments.map(fregment => {\n el.appendChild(fregment);\n });\n }\n\n return this;\n}\n\nfunction appendTo(selector) {\n let fregment, i = 0,\n elCollection = Clus.find(selector),\n els = Array.prototype.slice.apply(elCollection);\n\n while((fregment = this[i++])) {\n els.map(el => {\n el.appendChild(fregment);\n });\n }\n}\n\nfunction attr(attrs, value) {\n let attr, attrName, i = 0;\n\n if (arguments.length === 1 && typeof attrs === 'string' && this.length) {\n // get\n attr = this[0].getAttribute(attrs);\n return this[0] && (attr || attr === '') ? attr : undefined;\n } else {\n // set\n for (; i < this.length; i++) {\n if (arguments.length === 2) {\n // string\n this[i].setAttribute(attrs, value);\n } else {\n // object\n for (attrName in attrs) {\n this[i][attrName] = attrs[attrName];\n this[i].setAttribute(attrName, attrs[attrName]);\n }\n }\n }\n\n return this;\n }\n}\n\nfunction removeAttr(attr) {\n for (let i = 0; i < this.length; i++) {\n this[i].removeAttribute(attr);\n }\n\n return this;\n}\n\nClus.fn.extend({\n ready,\n addClass,\n removeClass,\n hasClass,\n toggleClass,\n append,\n appendTo,\n attr,\n removeAttr,\n});\n","//\n// ajax\n//\n\n/**\n * Initiate a Ajax request\n *\n * @method ajax\n * @param {Object} option\n */\nfunction ajax(option = {}) {\n let xhr = new XMLHttpRequest(),\n type = option.type.toUpperCase() || 'GET',\n url = option.url || '',\n data = option.data,\n success = option.success || function success() {},\n error = option.error || function error() {},\n params;\n\n params = (function (data) {\n let params = '', prop;\n for (prop in data) {\n if (data.hasOwnProperty(prop)) {\n params += prop + '=' + data[prop] + '&';\n }\n }\n params = params.slice(0, params.length - 1);\n return params;\n })(data);\n\n if (!url) console.error('url must be specified.');\n\n if (type === 'GET') url += url.indexOf('?') === -1 ? '?' + params : '&' + params;\n\n xhr.open(type, url);\n\n if (type === 'POST') xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n\n xhr.send(params ? params : null);\n\n xhr.onload = function () {\n if (xhr.status === 200) {\n success(resToJson(xhr.response));\n } else {\n error(resToJson(xhr.response));\n }\n };\n}\n\n/**\n * Parse response to json\n *\n * @method resToJson\n * @param {String} response\n * @return {Object} object\n */\nfunction resToJson(response) {\n return JSON.parse(response);\n}\n\nClus.extend({\n ajax,\n});\n","//\n// css\n//\n\nconst humpRE = /\\-(\\w)/g;\n\nfunction humpize(rules) {\n return rules.replace(humpRE, (_, letter) => letter.toUpperCase());\n}\n\nfunction css(rules, value) {\n let rule;\n if (Clus.type(rules) === 'string') {\n if (value === '' || Clus.type(value) === 'undefined' || Clus.type(value) === 'null') {\n return document.defaultView.getComputedStyle(this[0], null).getPropertyValue(rules);\n } else {\n this.each(el => el.style[humpize(rules)] = value);\n }\n } else {\n for (rule in rules) {\n this.each(el => el.style[humpize(rule)] = rules[rule]);\n }\n }\n return this;\n}\n\nfunction width(width) {\n if (width !== undefined) {\n this.each(el => {\n el.style.width = `${width}px`;\n });\n }\n\n let el = this[0];\n\n switch (el) {\n case window: {\n return window.innerWidth;\n }\n case document: {\n return document.documentElement.scrollWidth;\n }\n default: {\n return this.length > 0 ? parseFloat(this.css('width')) : null;\n }\n }\n}\n\nfunction height(height) {\n if (height !== undefined) {\n this.each(el => {\n el.style.height = `${height}px`;\n });\n }\n\n let el = this[0];\n\n switch (el) {\n case window: {\n return window.innerHeight;\n }\n case document: {\n let body = document.body,\n html = document.documentElement,\n heights = [body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight];\n\n return Math.max.apply(Math, heights);\n }\n default: {\n return this.length > 0 ? parseFloat(this.css('height')) : null;\n }\n }\n}\n\nClus.fn.extend({\n css,\n width,\n height,\n});\n"],"names":["init","selector","dom","fragmentRE","selectorType","Clus","type","elementTypes","indexOf","nodeType","window","document","ready","test","parseHTML","slice","call","querySelectorAll","extend","fn","options","name","clone","copy","source","copyIsArray","target","arguments","i","length","deep","this","isPlainObject","Array","isArray","undefined","rootQuery","trim","text","rtrim","replace","object","class2type","toString","typeString","split","forEach","toLowerCase","proto","ctor","hasOwnProperty","fnToString","hasOwn","Object","getPrototypeOf","constructor","ObjectFunctionString","isWindow","isDocument","DOCUMENT_NODE","isArrayLike","len","flatten","array","ret","el","push","apply","map","items","callback","value","values","each","merge","first","second","j","unique","matches","element","matchesSelector","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","DOMString","htmlDoc","implementation","createHTMLDocument","body","innerHTML","children","is","instanceMap","item","index","instanceEach","every","on","eventName","handler","capture","handleLiveEvent","event","k","parents","handleNamespaces","elm","namespace","DomNameSpaces","addEventListener","events","DomLiveListeners","off","removeEvents","parts","ns","that","removeEventListener","removed","splice","substr","liveListener","trigger","eventData","evt","CustomEvent","e","createEvent","initEvent","detail","dispatchEvent","pushStack","els","contructor","prevObject","find","end","eq","last","parent","parentNode","childNodes","readyState","getClass","getAttribute","addClass","cls","classes","clazz","cur","curValue","finalValue","match","rnotwhite","rclass","setAttribute","removeClass","hasClass","className","toggleClass","append","fregmentCollection","fregments","prototype","appendChild","fregment","appendTo","elCollection","attr","attrs","attrName","removeAttr","removeAttribute","ajax","option","xhr","XMLHttpRequest","toUpperCase","url","data","success","error","params","prop","console","open","setRequestHeader","send","onload","status","resToJson","response","JSON","parse","humpize","rules","humpRE","_","letter","css","rule","defaultView","getComputedStyle","getPropertyValue","style","width","innerWidth","documentElement","scrollWidth","parseFloat","height","innerHeight","html","heights","scrollHeight","offsetHeight","clientHeight","Math","max","C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"}
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clus",
3 | "version": "1.1.2",
4 | "description": "A minimalist JavaScript library for modern browsers.",
5 | "main": "dist/clus.js",
6 | "scripts": {
7 | "test": "mocha-phantomjs test/index.html",
8 | "start": "npm run watch",
9 | "build": "rm -rf dist && npm run dev",
10 | "watch": "NODE_ENV=development rollup -w -c rollup.config.js",
11 | "dev": "NODE_ENV=development rollup -c rollup.config.js",
12 | "prod": "NODE_ENV=production rollup -c rollup.config.js",
13 | "publish": "rm -rf dist && npm run dev && npm run prod",
14 | "lint": "eslint src"
15 | },
16 | "repository": {
17 | "type": "git",
18 | "url": "https://github.com/JustClear/clus.git"
19 | },
20 | "keywords": [
21 | "clus",
22 | "library",
23 | "class",
24 | "dom"
25 | ],
26 | "author": "JustClear",
27 | "license": "MIT",
28 | "bugs": {
29 | "url": "https://github.com/JustClear/clus/issues"
30 | },
31 | "homepage": "https://github.com/JustClear/clus",
32 | "devDependencies": {
33 | "babel-eslint": "^6.1.0",
34 | "babel-preset-es2015-rollup": "^1.1.1",
35 | "eslint": "^3.3.1",
36 | "expect.js": "^0.3.1",
37 | "mocha": "^3.0.2",
38 | "mocha-phantomjs": "^4.1.0",
39 | "rollup": "^0.34.10",
40 | "rollup-plugin-babel": "^2.6.1",
41 | "rollup-plugin-sourcemaps": "^0.3.4",
42 | "rollup-plugin-uglify": "^1.0.1",
43 | "rollup-watch": "^2.4.0"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | //
2 | // Rollup configure file
3 | //
4 |
5 | import babel from 'rollup-plugin-babel';
6 | import uglify from 'rollup-plugin-uglify';
7 | import sourcemaps from 'rollup-plugin-sourcemaps';
8 |
9 | const paths = {
10 | root: '/',
11 | source: {
12 | root: './src/',
13 | modules: './src/modules/',
14 | },
15 | dist: {
16 | root: './dist/',
17 | },
18 | };
19 |
20 | let fileName,
21 | Configure;
22 |
23 | fileName = process.env.NODE_ENV === 'development' ? 'clus' : 'clus.min';
24 |
25 | Configure = {
26 | format: 'umd', // 'amd', 'cjs', 'es', 'iife', 'umd'
27 | moduleName: 'Clus',
28 | moduleId: 'Clus',
29 | entry: `${paths.source.root}index.js`,
30 | dest: `${paths.dist.root}${fileName}.js`,
31 | sourceMap: true,
32 | plugins: [
33 | babel(),
34 | sourcemaps(),
35 | ],
36 | };
37 |
38 | if (process.env.NODE_ENV === 'production') {
39 | Configure.plugins.push(uglify());
40 | }
41 |
42 | export default Configure;
43 |
--------------------------------------------------------------------------------
/src/ajax.js:
--------------------------------------------------------------------------------
1 | //
2 | // ajax
3 | //
4 |
5 | /**
6 | * Initiate a Ajax request
7 | *
8 | * @method ajax
9 | * @param {Object} option
10 | */
11 | function ajax(option = {}) {
12 | let xhr = new XMLHttpRequest(),
13 | type = option.type.toUpperCase() || 'GET',
14 | url = option.url || '',
15 | data = option.data,
16 | success = option.success || function success() {},
17 | error = option.error || function error() {},
18 | params;
19 |
20 | params = (function (data) {
21 | let params = '', prop;
22 | for (prop in data) {
23 | if (data.hasOwnProperty(prop)) {
24 | params += prop + '=' + data[prop] + '&';
25 | }
26 | }
27 | params = params.slice(0, params.length - 1);
28 | return params;
29 | })(data);
30 |
31 | if (!url) console.error('url must be specified.');
32 |
33 | if (type === 'GET') url += url.indexOf('?') === -1 ? '?' + params : '&' + params;
34 |
35 | xhr.open(type, url);
36 |
37 | if (type === 'POST') xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
38 |
39 | xhr.send(params ? params : null);
40 |
41 | xhr.onload = function () {
42 | if (xhr.status === 200) {
43 | success(resToJson(xhr.response));
44 | } else {
45 | error(resToJson(xhr.response));
46 | }
47 | };
48 | }
49 |
50 | /**
51 | * Parse response to json
52 | *
53 | * @method resToJson
54 | * @param {String} response
55 | * @return {Object} object
56 | */
57 | function resToJson(response) {
58 | return JSON.parse(response);
59 | }
60 |
61 | Clus.extend({
62 | ajax,
63 | });
64 |
--------------------------------------------------------------------------------
/src/core/core.js:
--------------------------------------------------------------------------------
1 | //
2 | // core
3 | //
4 |
5 | import init from './init';
6 | import extend from './extend';
7 |
8 | /**
9 | * Constructor
10 | *
11 | * @constructor Clus
12 | * @method Clus
13 | * @param {String} selector
14 | */
15 | export default function Clus (selector) {
16 | return new Clus.fn.init(selector);
17 | }
18 |
19 | Clus.fn = Clus.prototype = {
20 | contructor: Clus,
21 | init,
22 | };
23 |
24 | Clus.fn.init.prototype = Clus.fn;
25 |
26 | Clus.extend = Clus.fn.extend = extend;
27 |
28 | window.Clus = window.C = window.$ = Clus;
29 |
--------------------------------------------------------------------------------
/src/core/extend.js:
--------------------------------------------------------------------------------
1 | //
2 | // extend
3 | //
4 |
5 | /**
6 | * Extend object
7 | *
8 | * @method extend
9 | * @return {Object} object
10 | */
11 | export default function extend() {
12 | let options, name, clone, copy, source, copyIsArray,
13 | target = arguments[0] || {},
14 | i = 1,
15 | length = arguments.length,
16 | deep = false;
17 |
18 | if (typeof target === 'boolean') {
19 | deep = target;
20 | target = arguments[i] || {};
21 | i++;
22 | }
23 |
24 | if (typeof target !== 'object' && Clus.type(target) !== 'function') {
25 | target = {};
26 | }
27 |
28 | if (i === length) {
29 | target = this;
30 | i--;
31 | }
32 |
33 | for (; i < length; i++) {
34 | //
35 | if ((options = arguments[i]) !== null) {
36 | // for in source object
37 | for (name in options) {
38 |
39 | source = target[name];
40 | copy = options[name];
41 |
42 | if (target == copy) {
43 | continue;
44 | }
45 |
46 | // deep clone
47 | if (deep && copy && (Clus.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
48 | // if copy is array
49 | if (copyIsArray) {
50 | copyIsArray = false;
51 | // if is not array, set it to array
52 | clone = source && Array.isArray(source) ? source : [];
53 | } else {
54 | // if copy is not a object, set it to object
55 | clone = source && Clus.isPlainObject(source) ? source : {};
56 | }
57 |
58 | target[name] = extend(deep, clone, copy);
59 | } else if (copy !== undefined) {
60 | target[name] = copy;
61 | }
62 | }
63 | }
64 | }
65 |
66 | return target;
67 | }
68 |
--------------------------------------------------------------------------------
/src/core/init.js:
--------------------------------------------------------------------------------
1 | //
2 | // initialize
3 | //
4 |
5 | /**
6 | * Initialize
7 | *
8 | * @method init
9 | * @param {String} selector
10 | * @return {DOM} DOMList
11 | */
12 | export default function init(selector) {
13 | let dom,
14 | fragmentRE = /^\s*<(\w+|!)[^>]*>/,
15 | selectorType = Clus.type(selector),
16 | elementTypes = [1, 9, 11];
17 |
18 | if (!selector) {
19 | dom = [],
20 | dom.selector = selector;
21 | } else if (elementTypes.indexOf(selector.nodeType) !== -1 || selector === window) {
22 | dom = [selector],
23 | selector = null;
24 | } else if (selectorType === 'function') {
25 | return Clus(document).ready(selector);
26 | } else if (selectorType === 'array') {
27 | dom = selector;
28 | } else if (selectorType === 'object') {
29 | dom = [selector],
30 | selector = null;
31 | } else if (selectorType === 'string') {
32 | if (selector[0] === '<' && fragmentRE.test(selector)) {
33 | dom = Clus.parseHTML(selector),
34 | selector = null;
35 | } else {
36 | dom = [].slice.call(document.querySelectorAll(selector));
37 | }
38 | }
39 |
40 | dom = dom || [];
41 | Clus.extend(dom, Clus.fn);
42 | dom.selector = selector;
43 |
44 | return dom;
45 | }
46 |
--------------------------------------------------------------------------------
/src/css.js:
--------------------------------------------------------------------------------
1 | //
2 | // css
3 | //
4 |
5 | const humpRE = /\-(\w)/g;
6 |
7 | function humpize(rules) {
8 | return rules.replace(humpRE, (_, letter) => letter.toUpperCase());
9 | }
10 |
11 | function css(rules, value) {
12 | let rule;
13 | if (Clus.type(rules) === 'string') {
14 | if (value === '' || Clus.type(value) === 'undefined' || Clus.type(value) === 'null') {
15 | return document.defaultView.getComputedStyle(this[0], null).getPropertyValue(rules);
16 | } else {
17 | this.each(el => el.style[humpize(rules)] = value);
18 | }
19 | } else {
20 | for (rule in rules) {
21 | this.each(el => el.style[humpize(rule)] = rules[rule]);
22 | }
23 | }
24 | return this;
25 | }
26 |
27 | function width(width) {
28 | if (width !== undefined) {
29 | this.each(el => {
30 | el.style.width = `${width}px`;
31 | });
32 | }
33 |
34 | let el = this[0];
35 |
36 | switch (el) {
37 | case window: {
38 | return window.innerWidth;
39 | }
40 | case document: {
41 | return document.documentElement.scrollWidth;
42 | }
43 | default: {
44 | return this.length > 0 ? parseFloat(this.css('width')) : null;
45 | }
46 | }
47 | }
48 |
49 | function height(height) {
50 | if (height !== undefined) {
51 | this.each(el => {
52 | el.style.height = `${height}px`;
53 | });
54 | }
55 |
56 | let el = this[0];
57 |
58 | switch (el) {
59 | case window: {
60 | return window.innerHeight;
61 | }
62 | case document: {
63 | let body = document.body,
64 | html = document.documentElement,
65 | heights = [body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight];
66 |
67 | return Math.max.apply(Math, heights);
68 | }
69 | default: {
70 | return this.length > 0 ? parseFloat(this.css('height')) : null;
71 | }
72 | }
73 | }
74 |
75 | Clus.fn.extend({
76 | css,
77 | width,
78 | height,
79 | });
80 |
--------------------------------------------------------------------------------
/src/dom.js:
--------------------------------------------------------------------------------
1 | //
2 | // dom
3 | //
4 |
5 | const rnotwhite = /\S+/g;
6 | const rclass = /[\t\r\n\f]/g;
7 |
8 | function ready(callback) {
9 | if (
10 | document
11 | &&
12 | /complete|loaded|interactive/.test(document.readyState)
13 | &&
14 | document.body
15 | ) {
16 | callback();
17 | } else {
18 | document.addEventListener('DOMContentLoaded', function () {
19 | callback();
20 | }, false);
21 | }
22 |
23 | return this;
24 | }
25 |
26 | function getClass(el) {
27 | return el.getAttribute && el.getAttribute('class') || '';
28 | }
29 |
30 | function addClass(cls) {
31 | let classes, clazz, el, cur, curValue, finalValue, j, i = 0;
32 |
33 | if (typeof cls === 'string' && cls) {
34 | classes = cls.match(rnotwhite) || [];
35 |
36 | while((el = this[i++])) {
37 | curValue = getClass(el);
38 | cur = (el.nodeType === 1) && ` ${curValue} `.replace(rclass, ' ');
39 |
40 | if (cur) {
41 | j = 0;
42 |
43 | while((clazz = classes[j++])) {
44 | // to determine whether the class that to add has already existed
45 | if (cur.indexOf(` ${clazz} `) == -1) {
46 | cur += clazz + ' ';
47 | }
48 | finalValue = Clus.trim(cur);
49 | if ( curValue !== finalValue ) {
50 | el.setAttribute('class', finalValue);
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
57 | return this;
58 | }
59 |
60 | function removeClass(cls) {
61 | let classes, clazz, el, cur, curValue, finalValue, j, i = 0;
62 |
63 | if (!arguments.length) {
64 | return;
65 | }
66 |
67 | if (typeof cls === 'string' && cls) {
68 | classes = cls.match(rnotwhite) || [];
69 |
70 | while((el = this[i++])) {
71 | curValue = getClass(el);
72 | cur = (el.nodeType === 1) && ` ${curValue} `.replace(rclass, ' ');
73 |
74 | if (cur) {
75 | j = 0;
76 |
77 | while((clazz = classes[j++])) {
78 | // to determine whether the class that to add has already existed
79 | if (cur.indexOf(` ${clazz} `) !== -1) {
80 | cur = cur.replace(` ${clazz} `, ' ');
81 | }
82 | finalValue = Clus.trim(cur);
83 | if ( curValue !== finalValue ) {
84 | el.setAttribute('class', finalValue);
85 | }
86 | }
87 | }
88 | }
89 | }
90 |
91 | return this;
92 | }
93 |
94 | function hasClass(cls) {
95 | let el, i = 0, className = ` ${cls} `;
96 |
97 | while((el = this[i++])) {
98 | if (
99 | el.nodeType === 1
100 | &&
101 | ` ${getClass(el)} `.replace(rclass, ' ').indexOf(className) !== -1
102 | ) {
103 | return true;
104 | }
105 | }
106 |
107 | return false;
108 | }
109 |
110 | function toggleClass(cls) {
111 | let el, i = 0;
112 |
113 | while((el = this[i++])) {
114 | if (this.hasClass(cls)) {
115 | this.removeClass(cls);
116 | return this;
117 | } else {
118 | this.addClass(cls);
119 | return this;
120 | }
121 | }
122 | }
123 |
124 | function append(DOMString) {
125 | let el, i = 0,
126 | fregmentCollection = Clus.parseHTML(DOMString),
127 | fregments = Array.prototype.slice.apply(fregmentCollection);
128 |
129 | while((el = this[i++])) {
130 | fregments.map(fregment => {
131 | el.appendChild(fregment);
132 | });
133 | }
134 |
135 | return this;
136 | }
137 |
138 | function appendTo(selector) {
139 | let fregment, i = 0,
140 | elCollection = Clus.find(selector),
141 | els = Array.prototype.slice.apply(elCollection);
142 |
143 | while((fregment = this[i++])) {
144 | els.map(el => {
145 | el.appendChild(fregment);
146 | });
147 | }
148 | }
149 |
150 | function attr(attrs, value) {
151 | let attr, attrName, i = 0;
152 |
153 | if (arguments.length === 1 && typeof attrs === 'string' && this.length) {
154 | // get
155 | attr = this[0].getAttribute(attrs);
156 | return this[0] && (attr || attr === '') ? attr : undefined;
157 | } else {
158 | // set
159 | for (; i < this.length; i++) {
160 | if (arguments.length === 2) {
161 | // string
162 | this[i].setAttribute(attrs, value);
163 | } else {
164 | // object
165 | for (attrName in attrs) {
166 | this[i][attrName] = attrs[attrName];
167 | this[i].setAttribute(attrName, attrs[attrName]);
168 | }
169 | }
170 | }
171 |
172 | return this;
173 | }
174 | }
175 |
176 | function removeAttr(attr) {
177 | for (let i = 0; i < this.length; i++) {
178 | this[i].removeAttribute(attr);
179 | }
180 |
181 | return this;
182 | }
183 |
184 | Clus.fn.extend({
185 | ready,
186 | addClass,
187 | removeClass,
188 | hasClass,
189 | toggleClass,
190 | append,
191 | appendTo,
192 | attr,
193 | removeAttr,
194 | });
195 |
--------------------------------------------------------------------------------
/src/event.js:
--------------------------------------------------------------------------------
1 | //
2 | // event
3 | //
4 |
5 | function on(eventName, selector, handler, capture) {
6 | let events = eventName.split(' '), i, j;
7 |
8 | for (i = 0; i < this.length; i++) {
9 | if (Clus.type(selector) === 'function' || selector === false) {
10 | // Usual events
11 | if (Clus.type(selector) === 'function') {
12 | handler = arguments[1];
13 | capture = arguments[2] || false;
14 | }
15 | for (j = 0; j < events.length; j++) {
16 | // check for namespaces
17 | if (events[j].indexOf('.') !== -1) {
18 | handleNamespaces(this[i], events[j], handler, capture);
19 | } else {
20 | this[i].addEventListener(events[j], handler, capture);
21 | }
22 | }
23 | } else {
24 | // Live events
25 | for (j = 0; j < events.length; j++) {
26 | if (!this[i].DomLiveListeners) {
27 | this[i].DomLiveListeners = [];
28 | }
29 |
30 | this[i].DomLiveListeners.push({
31 | handler: handler,
32 | liveListener: handleLiveEvent,
33 | });
34 |
35 | if (events[j].indexOf('.') !== -1) {
36 | handleNamespaces(this[i], events[j], handleLiveEvent, capture);
37 | } else {
38 | this[i].addEventListener(events[j], handleLiveEvent, capture);
39 | }
40 | }
41 | }
42 | }
43 |
44 | function handleLiveEvent(event) {
45 | let k,
46 | parents,
47 | target = event.target;
48 |
49 | if (Clus(target).is(selector)) {
50 | handler.call(target, event);
51 | } else {
52 | parents = Clus(target).parents();
53 | for (k = 0; k < parents.length; k++) {
54 | if (Clus(parents[k]).is(selector)) {
55 | handler.call(parents[k], event);
56 | }
57 | }
58 | }
59 | }
60 |
61 | function handleNamespaces(elm, name, handler, capture) {
62 | let namespace = name.split('.');
63 |
64 | if (!elm.DomNameSpaces) {
65 | elm.DomNameSpaces = [];
66 | }
67 |
68 | elm.DomNameSpaces.push({
69 | namespace: namespace[1],
70 | event: namespace[0],
71 | handler: handler,
72 | capture: capture,
73 | });
74 |
75 | elm.addEventListener(namespace[0], handler, capture);
76 | }
77 |
78 | return this;
79 | }
80 |
81 | function off(eventName, selector, handler, capture) {
82 | let events,
83 | i, j, k,
84 | that = this;
85 |
86 | events = eventName.split(' ');
87 |
88 | for (i = 0; i < events.length; i++) {
89 | for (j = 0; j < this.length; j++) {
90 | if (Clus.type(selector) === 'function' || selector === false) {
91 | // Usual events
92 | if (Clus.type(selector) === 'function') {
93 | handler = arguments[1];
94 | capture = arguments[2] || false;
95 | }
96 |
97 | if (events[i].indexOf('.') === 0) { // remove namespace events
98 | removeEvents(events[i].substr(1), handler, capture);
99 | } else {
100 | this[j].removeEventListener(events[i], handler, capture);
101 | }
102 | } else {
103 | // Live event
104 | if (this[j].DomLiveListeners) {
105 | for (k = 0; k < this[j].DomLiveListeners.length; k++) {
106 | if (this[j].DomLiveListeners[k].handler === handler) {
107 | this[j].removeEventListener(events[i], this[j].DomLiveListeners[k].liveListener, capture);
108 | }
109 | }
110 | }
111 | if (this[j].DomNameSpaces && this[j].DomNameSpaces.length && events[i]) {
112 | removeEvents(events[i]);
113 | }
114 | }
115 | }
116 | }
117 |
118 | function removeEvents(event) {
119 | let i, j,
120 | item,
121 | parts = event.split('.'),
122 | name = parts[0],
123 | ns = parts[1];
124 |
125 | for (i = 0; i < that.length; ++i) {
126 | if (that[i].DomNameSpaces) {
127 | for (j = 0; j < that[i].DomNameSpaces.length; ++j) {
128 | item = that[i].DomNameSpaces[j];
129 |
130 | if (item.namespace == ns && (item.event == name || !name)) {
131 | that[i].removeEventListener(item.event, item.handler, item.capture);
132 | item.removed = true;
133 | }
134 | }
135 | // remove the events from the DomNameSpaces array
136 | for (j = that[i].DomNameSpaces.length - 1; j >= 0; --j) {
137 | if (that[i].DomNameSpaces[j].removed) {
138 | that[i].DomNameSpaces.splice(j, 1);
139 | }
140 | }
141 | }
142 | }
143 | }
144 |
145 | return this;
146 | }
147 |
148 | function trigger(eventName, eventData) {
149 | let events = eventName.split(' '),
150 | i = 0,
151 | j = 0,
152 | evt;
153 | for (; i < events.length; i++) {
154 | for (; j < this.length; j++) {
155 | try {
156 | evt = new CustomEvent(events[i], {
157 | detail: eventData,
158 | bubbles: true,
159 | cancelable: true,
160 | });
161 | } catch (e) {
162 | evt = document.createEvent('Event');
163 | evt.initEvent(events[i], true, true);
164 | evt.detail = eventData;
165 | }
166 | this[j].dispatchEvent(evt);
167 | }
168 | }
169 |
170 | return this;
171 | }
172 |
173 | Clus.fn.extend({
174 | on,
175 | off,
176 | trigger,
177 | });
178 |
--------------------------------------------------------------------------------
/src/global.js:
--------------------------------------------------------------------------------
1 | //
2 | // global methods
3 | //
4 |
5 | export function rootQuery(selector) {
6 | return document.querySelectorAll(selector);
7 | }
8 |
9 | export function trim(text) {
10 | const rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
11 | return text == null ? '' : `${text}`.replace(rtrim, '');
12 | }
13 |
14 | export function type(object) {
15 | let class2type = {},
16 | type = class2type.toString.call(object),
17 | typeString = 'Boolean Number String Function Array Date RegExp Object Error Symbol';
18 |
19 | if (object == null) {
20 | return object + '';
21 | }
22 |
23 | typeString.split(' ').forEach((type) => {
24 | class2type[`[object ${type}]`] = type.toLowerCase();
25 | });
26 |
27 | return (
28 | typeof object === 'object' ||
29 | typeof object === 'function'
30 | ?
31 | class2type[type] || 'object'
32 | :
33 | typeof object
34 | );
35 | }
36 |
37 | export function isPlainObject(object) {
38 | let proto,
39 | ctor,
40 | class2type = {},
41 | toString = class2type.toString, // Object.prototype.toString
42 | hasOwn = class2type.hasOwnProperty,
43 | fnToString = hasOwn.toString, // Object.toString/Function.toString
44 | ObjectFunctionString = fnToString.call( Object ); // 'function Object() { [native code] }'
45 |
46 | if (!object || toString.call(object) !== '[object Object]') {
47 | return false;
48 | }
49 |
50 | // According to the object created by `Object.create(null)` is no `prototype`
51 | proto = Object.getPrototypeOf(object);
52 | if (!proto) {
53 | return true;
54 | }
55 |
56 | ctor = hasOwn.call(proto, 'constructor') && proto.constructor;
57 | return typeof ctor === 'function' && fnToString.call( ctor ) === ObjectFunctionString;
58 | }
59 |
60 | export function isWindow(object) {
61 | return object !== null && object === object.window;
62 | }
63 |
64 | export function isDocument(object) {
65 | return object !== null && object.nodeType == object.DOCUMENT_NODE;
66 | }
67 |
68 | export function isArrayLike(object) {
69 | let len = !!object && 'length' in object && object.length,
70 | type = Clus.type(object);
71 |
72 | if (type === 'function' || isWindow(object)) return false;
73 |
74 | return type === 'array' || len === 0 || typeof length === 'number' && len > 0 && (len - 1) in object;
75 | }
76 |
77 | export function flatten(array) {
78 | let ret = [],
79 | el,
80 | i = 0,
81 | len = array.length;
82 |
83 | for (; i < len; i++) {
84 | el = array[i];
85 | if (Array.isArray(el)) {
86 | ret.push.apply(ret, flatten(el));
87 | } else {
88 | ret.push(el);
89 | }
90 | }
91 | return ret;
92 | }
93 |
94 | export function map(items, callback) {
95 | let value, values = [], len, i = 0;
96 |
97 | if (isArrayLike(items)) {
98 | len = items.length;
99 | for (; i < len; i++) {
100 | value = callback(items[i], i);
101 | if (value != null) values.push(value);
102 | }
103 | } else {
104 | for (i in items) {
105 | value = callback(items[i], i);
106 | if (value != null) values.push(value);
107 | }
108 | }
109 |
110 | return flatten(values);
111 | }
112 |
113 | export function each(items, callback) {
114 | let len, i = 0;
115 |
116 | if ( isArrayLike(items) ) {
117 | len = items.length;
118 | for ( ; i < len; i++ ) {
119 | if (callback.call(items[i], items[i], i) === false) return items;
120 | }
121 | } else {
122 | for ( i in items ) {
123 | if (callback.call(items[i], items[i], i) === false) return items;
124 | }
125 | }
126 |
127 | return items;
128 | }
129 |
130 | export function merge(first, second) {
131 | let len = +second.length,
132 | j = 0,
133 | i = first.length;
134 |
135 | for ( ; j < len; j++ ) {
136 | first[ i++ ] = second[ j ];
137 | }
138 |
139 | first.length = i;
140 |
141 | return first;
142 | }
143 |
144 | export function unique(array) {
145 | let unique = [], i = 0, len = array.length;
146 | for (; i < len; i++) {
147 | if (unique.indexOf(array[i]) === -1) {
148 | unique.push(array[i]);
149 | }
150 | }
151 | return unique;
152 | }
153 |
154 | export function matches(element, selector) {
155 | if (!selector || !element || element.nodeType !== 1) return false;
156 |
157 | let matchesSelector = element.matchesSelector || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector;
158 |
159 | return matchesSelector.call(element, selector);
160 | }
161 |
162 | export function parseHTML(DOMString) {
163 | let htmlDoc = document.implementation.createHTMLDocument();
164 | htmlDoc.body.innerHTML = DOMString;
165 | return htmlDoc.body.children;
166 | }
167 |
168 | Clus.extend({
169 | find: rootQuery,
170 | type,
171 | isPlainObject,
172 | isWindow,
173 | isDocument,
174 | isArrayLike,
175 | each,
176 | map,
177 | merge,
178 | trim,
179 | unique,
180 | matches,
181 | parseHTML,
182 | });
183 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import './core/core';
2 | import './global';
3 | import './instance';
4 | import './event';
5 | import './search';
6 | import './dom';
7 | import './ajax';
8 | import './css';
9 |
--------------------------------------------------------------------------------
/src/instance.js:
--------------------------------------------------------------------------------
1 | //
2 | // instance methods
3 | //
4 |
5 | function is(selector) {
6 | return this.length > 0 && Clus.matches(this[0], selector);
7 | }
8 |
9 | function instanceMap(callback) {
10 | return Clus(Clus.map(this, function(item, index) {
11 | return callback.call(item, item, index);
12 | }));
13 | }
14 |
15 | function instanceEach(callback) {
16 | [].every.call(this, function(item, index) {
17 | return callback.call(item, item, index) !== false;
18 | });
19 | return this;
20 | }
21 |
22 | Clus.fn.extend({
23 | is,
24 | map: instanceMap,
25 | each: instanceEach,
26 | });
27 |
--------------------------------------------------------------------------------
/src/search.js:
--------------------------------------------------------------------------------
1 | //
2 | // dom search
3 | //
4 |
5 | function pushStack(els) {
6 | let ret = Clus.merge(this.contructor(), els);
7 | ret.prevObject = this;
8 | return ret;
9 | }
10 |
11 | function find(selector) {
12 | let i = 0,
13 | el,
14 | ret = this.pushStack([]);
15 |
16 | while((el = this[i++])) {
17 | ret = Clus.merge(ret, el.querySelectorAll(selector));
18 | }
19 |
20 | return ret;
21 | }
22 |
23 | function end() {
24 | return this.prevObject || this.contructor();
25 | }
26 |
27 | function eq(i) {
28 | let len = this.length,
29 | j = +i + ( i < 0 ? len : 0 ); // reverse find
30 | return this.pushStack(j >= 0 && j < len ? [this[j]] : []);
31 | }
32 |
33 | function first() {
34 | return this.eq(0);
35 | }
36 |
37 | function last() {
38 | return this.eq(-1);
39 | }
40 |
41 | function parent(selector) {
42 | let parents = [], i = 0, len = this.length;
43 | for (; i < len; i++) {
44 | if (this[i].parentNode !== null) {
45 | if (selector) {
46 | if (Clus(this[i].parentNode).is(selector)) {
47 | parents.push(this[i].parentNode);
48 | }
49 | } else {
50 | parents.push(this[i].parentNode);
51 | }
52 | }
53 | }
54 | parents = Clus.unique(parents);
55 | return Clus(parents);
56 | }
57 |
58 | function parents(selector) {
59 | let parent, parents = [], i = 0, len = this.length;
60 | for (; i < len; i++) {
61 | parent = this[i].parentNode;
62 | while (parent) {
63 | if (selector) {
64 | if (Clus(parent).is(selector)) {
65 | parents.push(parent);
66 | }
67 | } else {
68 | parents.push(parent);
69 | }
70 | parent = parent.parentNode;
71 | }
72 | }
73 | parents = Clus.unique(parents);
74 | return Clus(parents);
75 | }
76 |
77 | function children(selector) {
78 | let children = [], childNodes, i = 0, j = 0, len = this.length;
79 | for (; i < len; i++) {
80 | childNodes = this[i].childNodes;
81 | for (; j < childNodes.length; j++) {
82 | if (!selector) {
83 | if (childNodes[j].nodeType === 1) {
84 | children.push(childNodes[j]);
85 | }
86 | } else {
87 | if (childNodes[j].nodeType === 1 && Clus(childNodes[j]).is(selector)) {
88 | children.push(childNodes[j]);
89 | }
90 | }
91 | }
92 | }
93 |
94 | return Clus(Clus.unique(children));
95 | }
96 |
97 | Clus.fn.extend({
98 | pushStack,
99 | find,
100 | end,
101 | eq,
102 | first,
103 | last,
104 | parent,
105 | parents,
106 | children,
107 | });
108 |
--------------------------------------------------------------------------------
/test/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Clus test
8 |
9 |
10 |
11 |
12 |
13 |
14 |
17 |
18 |
19 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/test/unit/core.js:
--------------------------------------------------------------------------------
1 | //
2 |
3 | describe('Core Test', function () {
4 | it('$.trim()', function () {
5 | expect($.trim('hello Clus. ')).to.equal('hello Clus.');
6 | })
7 | it('$.type()', function () {
8 | expect($.type('')).to.equal('string');
9 | expect($.type({})).to.equal('object');
10 | expect($.type(true)).to.equal('boolean');
11 | })
12 | it('$(selector)', function () {
13 | expect($('body')[0]).to.equal(document.querySelectorAll('body')[0]);
14 | expect($('.mocha')[0]).to.equal(document.querySelectorAll('.mocha')[0]);
15 | expect($('#mocha')[0]).to.equal(document.querySelectorAll('#mocha')[0]);
16 | })
17 | it('$(DOMNode)', function () {
18 | expect($(document)[0]).to.equal(document);
19 | expect($(window)[0]).to.equal(window);
20 | })
21 | });
22 |
--------------------------------------------------------------------------------