You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2022/07/19 08:20:36 UTC
[echarts] 01/01: refactor(util): import `encodeHTML` function from `zrender`.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch fix-import
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 690ad3df046d03e9c3e83fb4621d553bfc78bd7b
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Tue Jul 19 15:38:04 2022 +0800
refactor(util): import `encodeHTML` function from `zrender`.
---
src/util/format.ts | 20 ++------------------
1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/src/util/format.ts b/src/util/format.ts
index ce85f6c83..8aa00685a 100644
--- a/src/util/format.ts
+++ b/src/util/format.ts
@@ -18,6 +18,7 @@
*/
import * as zrUtil from 'zrender/src/core/util';
+import { encodeHTML } from 'zrender/src/core/dom';
import { parseDate, isNumeric, numericToNumber } from './number';
import { TooltipRenderMode, ColorString, ZRColor, DimensionType } from './types';
import { Dictionary } from 'zrender/src/core/types';
@@ -51,24 +52,7 @@ export function toCamelCase(str: string, upperCaseFirst?: boolean): string {
export const normalizeCssArray = zrUtil.normalizeCssArray;
-
-const replaceReg = /([&<>"'])/g;
-const replaceMap: Dictionary<string> = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- '\'': '''
-};
-
-export function encodeHTML(source: string): string {
- return source == null
- ? ''
- : (source + '').replace(replaceReg, function (str, c) {
- return replaceMap[c];
- });
-}
-
+export { encodeHTML };
/**
* Make value user readable for tooltip and label.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org