ph-utils 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  ### 后端(node server)
6
6
 
7
- 包含了一些 node 后端开发(web server) 时常用的工具类,包括 `index` 基础工具类(这个类里面的函数同样也适用于前端)、`date` 跟日期相关的工具类、`file` 文件操作相关工具类、`server` 一些只适用于后端的工具(使用了后端的 API 列表)
7
+ 包含了一些 node 后端开发(web server) 时常用的工具类,包括 `index` 基础工具类(这个类里面的函数同样也适用于前端)、`date` 跟日期相关的工具类、`file` 文件操作相关工具类、`server` 一些只适用于后端的工具(使用了后端的 API 列表)、`validator` 数据验证
8
8
 
9
9
  ### 前端(web)
10
10
 
11
- 包含了一些前端网站开发时常用的工具类,包括 `index` 基础工具类(这个类里面的函数同样也适用于前端)、`date` 跟日期相关的工具类、`dom` 浏览器节点操作相关、`web` 一些只适用于前端相关的工具 s
11
+ 包含了一些前端网站开发时常用的工具类,包括 `index` 基础工具类(这个类里面的函数同样也适用于前端)、`date` 跟日期相关的工具类、`dom` 浏览器节点操作相关、`web` 一些只适用于前端相关的工具、`validator` 数据验证
package/lib/dom.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * 根据选择器获取节点
3
3
  * @param {string} selector 选择器
4
4
  */
5
- export declare function elem(selector: string, dom?: HTMLElement): NodeListOf<HTMLElement>;
5
+ export declare function elem(selector: string | HTMLElement, dom?: HTMLElement): NodeListOf<HTMLElement> | HTMLElement[];
6
6
  /**
7
7
  * 为节点添加 class
8
8
  * @param {HTMLElement} elem 待添加 class 的节点
@@ -32,7 +32,7 @@ export declare function transform(element: HTMLElement, value: string): void;
32
32
  * @param {HTMLElement} element 添加事件的节点
33
33
  * @param {string} listener 事件名称
34
34
  * @param {function} event 事件处理函数
35
- * @param {boolean} onceOrConfig 是否是只运行一次的处理函数或者配置,其中 eventFlag 为 string,如果配置该项,则表明为委托事件;eventStop 表明是否在点击了事件节点时触发,默认为 false
35
+ * @param {boolean} onceOrConfig 是否是只运行一次的处理函数或者配置,其中 eventFlag 为 string,如果配置该项,则表明为委托事件
36
36
  */
37
37
  export declare function on(element: HTMLElement, listener: string, fn: (e: Event, target?: HTMLElement, flag?: string) => void, once?: boolean | {
38
38
  once?: boolean;
package/lib/dom.js CHANGED
@@ -9,7 +9,12 @@ const vendorPrefix = ['', '-webkit', '-moz-'];
9
9
  * @param {string} selector 选择器
10
10
  */
11
11
  export function elem(selector, dom) {
12
- return (dom || document).querySelectorAll(selector);
12
+ if (typeof selector === 'string') {
13
+ return (dom || document).querySelectorAll(selector);
14
+ }
15
+ else {
16
+ return [selector];
17
+ }
13
18
  }
14
19
  /**
15
20
  * 为节点添加 class
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module": "lib/index_m.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "browser": "lib/index_m.js",
8
- "version": "0.2.0",
8
+ "version": "0.2.1",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https//gitee.com/towardly/ph.git",