Comparing version 3.3.1 to 3.3.2
[English](./CHANGELOG.md) | 简体中文 | ||
#### V3.3.1 (2019-06-30) | ||
#### V3.3.2 (2019-07-04) | ||
@@ -5,0 +5,0 @@ - 【特性】增加 TypeScript 声明文件。(by @jas0ncn) |
English | [简体中文](./CHANGELOG_CN.md) | ||
#### V3.3.1 (2019-06-30) | ||
#### V3.3.2 (2019-07-04) | ||
@@ -5,0 +5,0 @@ - [FEATURE] Add TypeScript definition file. (by by @jas0ncn) |
{ | ||
"name": "vconsole", | ||
"version": "3.3.1", | ||
"version": "3.3.2", | ||
"description": "A lightweight, extendable front-end developer tool for mobile web page.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Tencent/vConsole", |
@@ -26,3 +26,7 @@ /* | ||
$.one = function(selector, contextElement) { | ||
return (contextElement || document).querySelector(selector) | ||
try { | ||
return (contextElement || document).querySelector(selector) || undefined; | ||
} catch (e) { | ||
return undefined; | ||
} | ||
} | ||
@@ -35,4 +39,8 @@ | ||
$.all = function(selector, contextElement) { | ||
const nodeList = (contextElement || document).querySelectorAll(selector) | ||
return Array.from(nodeList) | ||
try { | ||
const nodeList = (contextElement || document).querySelectorAll(selector); | ||
return Array.from(nodeList); | ||
} catch (e) { | ||
return []; | ||
} | ||
} | ||
@@ -52,9 +60,9 @@ | ||
for (let i=0; i<$el.length; i++) { | ||
if (isArray(className)) { | ||
className.forEach(name => $el[0].classList.add(name)); | ||
} else if (className.split(' ')[1]) { | ||
className.split(' ').forEach(name => $el[0].classList.add(name)) | ||
} else { | ||
$el[0].classList.add(className); | ||
let name = $el[i].className || '', | ||
arr = name.split(' '); | ||
if (arr.indexOf(className) > -1) { | ||
continue; | ||
} | ||
arr.push(className); | ||
$el[i].className = arr.join(' '); | ||
} | ||
@@ -75,9 +83,9 @@ } | ||
for (let i=0; i<$el.length; i++) { | ||
if (isArray(className)) { | ||
className.forEach(name => $el[0].classList.remove(name)); | ||
} else if (className.split(' ')[1]) { | ||
className.split(' ').forEach(name => $el[0].classList.remove(name)) | ||
} else { | ||
$el[0].classList.remove(className); | ||
let arr = $el[i].className.split(' '); | ||
for (let j=0; j<arr.length; j++) { | ||
if (arr[j] == className) { | ||
arr[j] = ''; | ||
} | ||
} | ||
$el[i].className = arr.join(' ').trim(); | ||
} | ||
@@ -91,6 +99,6 @@ } | ||
$.hasClass = function($el, className) { | ||
if (!$el) { | ||
if (!$el || !$el.classList) { | ||
return false; | ||
} | ||
return $el.classList.contains(className) | ||
return $el.classList.contains(className); | ||
} | ||
@@ -113,3 +121,5 @@ | ||
} | ||
$el.forEach(el => el.addEventListener(eventType, fn, !!useCapture)) | ||
$el.forEach((el) => { | ||
el.addEventListener(eventType, fn, !!useCapture); | ||
}) | ||
} | ||
@@ -116,0 +126,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1318222
82
4395