08-27-周三_17-09-29

This commit is contained in:
2025-08-27 17:10:05 +08:00
commit 86df397d8f
12735 changed files with 1145479 additions and 0 deletions

22
node_modules/delegate/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,22 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
# Change these settings to your own preference
indent_style = space
indent_size = 4
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[{package.json,bower.json}]
indent_size = 2

3
node_modules/delegate/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,3 @@
language: node_js
node_js:
- stable

29
node_modules/delegate/demo/delegate.html generated vendored Normal file
View File

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Delegate</title>
</head>
<body>
<!-- 1. Write some markup -->
<ul>
<li><button>Item 1</button></li>
<li><button>Item 2</button></li>
<li><button>Item 3</button></li>
<li><button>Item 4</button></li>
<li><button>Item 5</button></li>
</ul>
<!-- 2. Include library -->
<script src="../dist/delegate.js"></script>
<!-- 3. Add event delegation -->
<script>
var ul = document.querySelector('ul');
delegate(ul, 'button', 'click', function(e) {
console.log(e.target);
});
</script>
</body>
</html>

37
node_modules/delegate/demo/multiple.html generated vendored Normal file
View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Delegate</title>
</head>
<body>
<!-- 1. Write some markup -->
<ul>
<li><button>Item 1</button></li>
<li><button>Item 2</button></li>
<li><button>Item 3</button></li>
<li><button>Item 4</button></li>
<li><button>Item 5</button></li>
</ul>
<ul>
<li><span>Item 6</span></li>
<li><span>Item 7</span></li>
</ul>
<!-- 2. Include library -->
<script src="../dist/delegate.js"></script>
<!-- 3. Add event delegation -->
<script>
var ul = document.querySelector('ul');
delegate(ul, 'button', 'click', function(e) {
console.log(e.target);
});
delegate(document.body, 'span', 'click', function(e) {
console.log(e.target);
});
</script>
</body>
</html>

31
node_modules/delegate/demo/undelegate.html generated vendored Normal file
View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Undelegate</title>
</head>
<body>
<!-- 1. Write some markup -->
<ul>
<li><button>Item 1</button></li>
<li><button>Item 2</button></li>
<li><button>Item 3</button></li>
<li><button>Item 4</button></li>
<li><button>Item 5</button></li>
</ul>
<!-- 2. Include library -->
<script src="../dist/delegate.js"></script>
<!-- 3. Remove event delegation -->
<script>
var ul = document.querySelector('ul');
var delegation = delegate(ul, 'li button', 'click', function(e) {
console.log(e.target);
});
delegation.destroy();
</script>
</body>
</html>

80
node_modules/delegate/dist/delegate.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.delegate = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var DOCUMENT_NODE_TYPE = 9;
/**
* A polyfill for Element.matches()
*/
if (typeof Element !== 'undefined' && !Element.prototype.matches) {
var proto = Element.prototype;
proto.matches = proto.matchesSelector ||
proto.mozMatchesSelector ||
proto.msMatchesSelector ||
proto.oMatchesSelector ||
proto.webkitMatchesSelector;
}
/**
* Finds the closest parent that matches a selector.
*
* @param {Element} element
* @param {String} selector
* @return {Function}
*/
function closest (element, selector) {
while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
if (element.matches(selector)) return element;
element = element.parentNode;
}
}
module.exports = closest;
},{}],2:[function(require,module,exports){
var closest = require('./closest');
/**
* Delegates event to a selector.
*
* @param {Element} element
* @param {String} selector
* @param {String} type
* @param {Function} callback
* @param {Boolean} useCapture
* @return {Object}
*/
function delegate(element, selector, type, callback, useCapture) {
var listenerFn = listener.apply(this, arguments);
element.addEventListener(type, listenerFn, useCapture);
return {
destroy: function() {
element.removeEventListener(type, listenerFn, useCapture);
}
}
}
/**
* Finds closest match and invokes callback.
*
* @param {Element} element
* @param {String} selector
* @param {String} type
* @param {Function} callback
* @return {Function}
*/
function listener(element, selector, type, callback) {
return function(e) {
e.delegateTarget = closest(e.target, selector);
if (e.delegateTarget) {
callback.call(element, e);
}
}
}
module.exports = delegate;
},{"./closest":1}]},{},[2])(2)
});

24
node_modules/delegate/karma.conf.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
module.exports = function(karma) {
karma.set({
plugins: ['karma-browserify', 'karma-chai', 'karma-sinon', 'karma-mocha', 'karma-phantomjs-launcher'],
frameworks: ['browserify', 'chai', 'sinon', 'mocha'],
files: [
'src/**/*.js',
'test/**/*.js',
'./node_modules/phantomjs-polyfill/bind-polyfill.js'
],
preprocessors: {
'src/**/*.js' : ['browserify'],
'test/**/*.js': ['browserify']
},
browserify: {
debug: true
},
browsers: ['PhantomJS']
});
}

99
node_modules/delegate/package.json generated vendored Normal file
View File

@@ -0,0 +1,99 @@
{
"_args": [
[
{
"name": "delegate",
"raw": "delegate@^3.1.2",
"rawSpec": "^3.1.2",
"scope": null,
"spec": ">=3.1.2 <4.0.0",
"type": "range"
},
"F:\\tmp\\gitbook\\node_modules\\good-listener"
]
],
"_from": "delegate@>=3.1.2 <4.0.0",
"_id": "delegate@3.2.0",
"_inCache": true,
"_installable": true,
"_location": "/delegate",
"_nodeVersion": "8.9.1",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/delegate-3.2.0.tgz_1512501415362_0.5138437198475003"
},
"_npmUser": {
"email": "zno.rocha@gmail.com",
"name": "zenorocha"
},
"_npmVersion": "5.5.1",
"_phantomChildren": {},
"_requested": {
"name": "delegate",
"raw": "delegate@^3.1.2",
"rawSpec": "^3.1.2",
"scope": null,
"spec": ">=3.1.2 <4.0.0",
"type": "range"
},
"_requiredBy": [
"/good-listener"
],
"_resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
"_shasum": "b66b71c3158522e8ab5744f720d8ca0c2af59166",
"_shrinkwrap": null,
"_spec": "delegate@^3.1.2",
"_where": "F:\\tmp\\gitbook\\node_modules\\good-listener",
"bugs": {
"url": "https://github.com/zenorocha/delegate/issues"
},
"dependencies": {},
"description": "Lightweight event delegation",
"devDependencies": {
"browserify": "^13.1.0",
"chai": "^3.5.0",
"karma": "^1.3.0",
"karma-browserify": "^5.1.0",
"karma-chai": "^0.1.0",
"karma-mocha": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sinon": "^1.0.4",
"mocha": "^3.1.2",
"phantomjs-polyfill": "0.0.2",
"simulant": "^0.2.2",
"sinon": "^1.17.6"
},
"directories": {},
"dist": {
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
"shasum": "b66b71c3158522e8ab5744f720d8ca0c2af59166",
"tarball": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz"
},
"gitHead": "1fe374c9693576ebf95c42edeb59ebe146aef58f",
"homepage": "https://github.com/zenorocha/delegate#readme",
"keywords": [
"event",
"delegate",
"delegation"
],
"license": "MIT",
"main": "src/delegate.js",
"maintainers": [
{
"email": "zno.rocha@gmail.com",
"name": "zenorocha"
}
],
"name": "delegate",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/zenorocha/delegate.git"
},
"scripts": {
"build": "browserify src/delegate.js -s delegate -o dist/delegate.js",
"test": "karma start --single-run"
},
"version": "3.2.0"
}

99
node_modules/delegate/readme.md generated vendored Normal file
View File

@@ -0,0 +1,99 @@
# delegate
Lightweight event delegation.
## Install
You can get it on npm.
```
npm install delegate --save
```
If you're not into package management, just [download a ZIP](https://github.com/zenorocha/delegate/archive/master.zip) file.
## Setup
###### Node (Browserify)
```js
var delegate = require('delegate');
```
###### Browser (Standalone)
```html
<script src="dist/delegate.js"></script>
```
## Usage
### Add event delegation
#### With the default base (`document`)
```js
delegate('.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
```
#### With an element as base
```js
delegate(document.body, '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
```
#### With a selector (of existing elements) as base
```js
delegate('.container', '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
```
#### With an array/array-like of elements as base
```js
delegate(document.querySelectorAll('.container'), '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
```
### Remove event delegation
#### With a single base element (default or specified)
```js
var delegation = delegate(document.body, '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
delegation.destroy();
```
#### With multiple elements (via selector or array)
Note: selectors are always treated as multiple elements, even if one or none are matched. `delegate()` will return an array.
```js
var delegations = delegate('.container', '.btn', 'click', function(e) {
console.log(e.delegateTarget);
}, false);
delegations.forEach(function (delegation) {
delegation.destroy();
});
```
## Browser Support
| <img src="https://clipboardjs.com/assets/images/chrome.png" width="48px" height="48px" alt="Chrome logo"> | <img src="https://clipboardjs.com/assets/images/edge.png" width="48px" height="48px" alt="Edge logo"> | <img src="https://clipboardjs.com/assets/images/firefox.png" width="48px" height="48px" alt="Firefox logo"> | <img src="https://clipboardjs.com/assets/images/ie.png" width="48px" height="48px" alt="Internet Explorer logo"> | <img src="https://clipboardjs.com/assets/images/opera.png" width="48px" height="48px" alt="Opera logo"> | <img src="https://clipboardjs.com/assets/images/safari.png" width="48px" height="48px" alt="Safari logo"> |
|:---:|:---:|:---:|:---:|:---:|:---:|
| Latest ✔ | Latest ✔ | Latest ✔ | 9+ ✔ | Latest ✔ | Latest ✔ |
## License
[MIT License](http://zenorocha.mit-license.org/) © Zeno Rocha

33
node_modules/delegate/src/closest.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
var DOCUMENT_NODE_TYPE = 9;
/**
* A polyfill for Element.matches()
*/
if (typeof Element !== 'undefined' && !Element.prototype.matches) {
var proto = Element.prototype;
proto.matches = proto.matchesSelector ||
proto.mozMatchesSelector ||
proto.msMatchesSelector ||
proto.oMatchesSelector ||
proto.webkitMatchesSelector;
}
/**
* Finds the closest parent that matches a selector.
*
* @param {Element} element
* @param {String} selector
* @return {Function}
*/
function closest (element, selector) {
while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
if (typeof element.matches === 'function' &&
element.matches(selector)) {
return element;
}
element = element.parentNode;
}
}
module.exports = closest;

78
node_modules/delegate/src/delegate.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
var closest = require('./closest');
/**
* Delegates event to a selector.
*
* @param {Element} element
* @param {String} selector
* @param {String} type
* @param {Function} callback
* @param {Boolean} useCapture
* @return {Object}
*/
function _delegate(element, selector, type, callback, useCapture) {
var listenerFn = listener.apply(this, arguments);
element.addEventListener(type, listenerFn, useCapture);
return {
destroy: function() {
element.removeEventListener(type, listenerFn, useCapture);
}
}
}
/**
* Delegates event to a selector.
*
* @param {Element|String|Array} [elements]
* @param {String} selector
* @param {String} type
* @param {Function} callback
* @param {Boolean} useCapture
* @return {Object}
*/
function delegate(elements, selector, type, callback, useCapture) {
// Handle the regular Element usage
if (typeof elements.addEventListener === 'function') {
return _delegate.apply(null, arguments);
}
// Handle Element-less usage, it defaults to global delegation
if (typeof type === 'function') {
// Use `document` as the first parameter, then apply arguments
// This is a short way to .unshift `arguments` without running into deoptimizations
return _delegate.bind(null, document).apply(null, arguments);
}
// Handle Selector-based usage
if (typeof elements === 'string') {
elements = document.querySelectorAll(elements);
}
// Handle Array-like based usage
return Array.prototype.map.call(elements, function (element) {
return _delegate(element, selector, type, callback, useCapture);
});
}
/**
* Finds closest match and invokes callback.
*
* @param {Element} element
* @param {String} selector
* @param {String} type
* @param {Function} callback
* @return {Function}
*/
function listener(element, selector, type, callback) {
return function(e) {
e.delegateTarget = closest(e.target, selector);
if (e.delegateTarget) {
callback.call(element, e);
}
}
}
module.exports = delegate;

45
node_modules/delegate/test/closest.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
var closest = require('../src/closest');
describe('closest', function() {
before(function() {
var html = '<div id="a">' +
'<div id="b">' +
'<div id="c"></div>' +
'</div>' +
'</div>';
document.body.innerHTML += html;
global.a = document.querySelector('#a');
global.b = document.querySelector('#b');
global.c = document.querySelector('#c');
});
after(function() {
document.body.innerHTML = '';
});
it('should return the closest parent based on the selector', function() {
assert.ok(closest(global.c, '#b'), global.b);
assert.ok(closest(global.c, '#a'), global.a);
assert.ok(closest(global.b, '#a'), global.a);
});
it('should return itself if the same selector is passed', function() {
assert.ok(closest(document.body, 'body'), document.body);
});
it('should not throw on elements without matches()', function() {
var fakeElement = {
nodeType: -1, // anything but DOCUMENT_NODE_TYPE
parentNode: null,
matches: undefined // undefined to emulate Elements without this function
};
try {
closest(fakeElement, '#a')
} catch (err) {
assert.fail();
}
});
});

116
node_modules/delegate/test/delegate.js generated vendored Normal file
View File

@@ -0,0 +1,116 @@
var delegate = require('../src/delegate');
var simulant = require('simulant');
describe('delegate', function() {
before(function() {
var html = '<ul>' +
'<li><a>Item 1</a></li>' +
'<li><a>Item 2</a></li>' +
'<li><a>Item 3</a></li>' +
'<li><a>Item 4</a></li>' +
'<li><a>Item 5</a></li>' +
'</ul>';
document.body.innerHTML += html;
global.container = document.querySelector('ul');
global.anchor = document.querySelector('a');
global.spy = sinon.spy(global.container, 'removeEventListener');
});
after(function() {
global.spy.restore();
document.body.innerHTML = '';
});
it('should add an event listener', function(done) {
delegate(global.container, 'a', 'click', function() {
done();
});
simulant.fire(global.anchor, simulant('click'));
});
it('should remove an event listener', function() {
var delegation = delegate(global.container, 'a', 'click', function() {});
delegation.destroy();
assert.ok(global.spy.calledOnce);
});
it('should use `document` if the element is unspecified', function(done) {
delegate('a', 'click', function() {
done();
});
simulant.fire(global.anchor, simulant('click'));
});
it('should remove an event listener the unspecified base (`document`)', function() {
var delegation = delegate('a', 'click', function() {});
var spy = sinon.spy(document, 'removeEventListener');
delegation.destroy();
assert.ok(spy.calledOnce);
spy.restore();
});
it('should add event listeners to all the elements in a base selector', function() {
var spy = sinon.spy();
delegate('li', 'a', 'click', spy);
var anchors = document.querySelectorAll('a');
simulant.fire(anchors[0], simulant('click'));
simulant.fire(anchors[1], simulant('click'));
assert.ok(spy.calledTwice);
});
it('should remove the event listeners from all the elements in a base selector', function() {
var items = document.querySelectorAll('li')
var spies = Array.prototype.map.call(items, function (li) {
return sinon.spy(li, 'removeEventListener');
});
var delegations = delegate('li', 'a', 'click', function() {});
delegations.forEach(function (delegation) {
delegation.destroy();
});
spies.every(function (spy) {
var success = spy.calledOnce;
spy.restore();
return success;
});
});
it('should add event listeners to all the elements in a base array', function() {
var spy = sinon.spy();
var items = document.querySelectorAll('li')
delegate(items, 'a', 'click', spy);
var anchors = document.querySelectorAll('a')
simulant.fire(anchors[0], simulant('click'));
simulant.fire(anchors[1], simulant('click'));
assert.ok(spy.calledTwice);
});
it('should remove the event listeners from all the elements in a base array', function() {
var items = document.querySelectorAll('li')
var spies = Array.prototype.map.call(items, function (li) {
return sinon.spy(li, 'removeEventListener');
});
var delegations = delegate(items, 'a', 'click', function() {});
delegations.forEach(function (delegation) {
delegation.destroy();
});
spies.every(function (spy) {
var success = spy.calledOnce;
spy.restore();
return success;
});
});
});