From 5e2b320400ca96daccd6f75c21fdfea52fd6077a Mon Sep 17 00:00:00 2001 From: devilwjp <9700616@qq.com> Date: Sat, 14 Sep 2024 15:59:57 +0800 Subject: [PATCH 1/3] fix:#144 --- src/overrideDom.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/overrideDom.js b/src/overrideDom.js index e88187e..48396cc 100644 --- a/src/overrideDom.js +++ b/src/overrideDom.js @@ -8,18 +8,19 @@ const domTopObject = { Document: {}, Element: {} } export function overwriteDomMethods(refDom) { Object.keys(domTopObject).forEach((key) => { domMethods.forEach((method) => { - const old = window[key].prototype[method] + const old = domTopObject[key][method] || window[key].prototype[method] if (!old) return domTopObject[key][method] = old window[key].prototype[method] = function (...args) { const oldResult = old.apply(this, args) if (oldResult && (oldResult.constructor !== NodeList || (oldResult.constructor === NodeList && oldResult.length > 0))) return oldResult // If each function of Document is called using apply, an error will occur. Here you need to use the native function of Element. - if (method === 'getElementById'){ - method = 'querySelector' + let currentMethod = method + if (currentMethod === 'getElementById'){ + currentMethod = 'querySelector' args = ['#' + args[0]] } - const nativeElementFn = domTopObject.Element[method] || Element.prototype[method] + const nativeElementFn = domTopObject.Element[currentMethod] || Element.prototype[currentMethod] return nativeElementFn.apply(refDom, args) } }) From 7103e81bf005881069513e513a05b91b692b4ded Mon Sep 17 00:00:00 2001 From: devilwjp <9700616@qq.com> Date: Sat, 14 Sep 2024 16:21:59 +0800 Subject: [PATCH 2/3] docs: update readme --- README.md | 19 ++++++++++++------- README_zhcn.md | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ee07e01..1dc96c7 100644 --- a/README.md +++ b/README.md @@ -126,9 +126,10 @@ First install `@vitejs/plugin-react`, `@vitejs/plugin-vue` and `@vitejs/plugin-v ```js import { defineConfig } from 'vite' -// if mode cjs, should use `veaury/vite/cjs` -import veauryVitePlugins from 'veaury/vite/esm' - +// If mode cjs(vite.config.cjs), should use `veaury/vite/cjs` +// If mode esm(vite.config.mjs), should use `veaury/vite/esm` +// If the configuration file of vite has a `.js` suffix(vite.config.js), it is recommended to import it in the following way. +import veauryVitePlugins from 'veaury/vite' export default defineConfig({ plugins: [ @@ -154,8 +155,10 @@ export default defineConfig({ ```js import { defineConfig } from 'vite' -// if mode cjs, should use `veaury/vite/cjs` -import veauryVitePlugins from 'veaury/vite/esm' +// If mode cjs(vite.config.cjs), should use `veaury/vite/cjs` +// If mode esm(vite.config.mjs), should use `veaury/vite/esm` +// If the configuration file of vite has a `.js` suffix(vite.config.js), it is recommended to import it in the following way. +import veauryVitePlugins from 'veaury/vite' export default defineConfig({ plugins: [ @@ -182,8 +185,10 @@ Use `vueJsxInclude` and `vueJsxExclude` to configure the file range to be parsed ```js import { defineConfig } from 'vite' -// if mode cjs, should use `veaury/vite/cjs` -import veauryVitePlugins from 'veaury/vite/esm' +// If mode cjs(vite.config.cjs), should use `veaury/vite/cjs` +// If mode esm(vite.config.mjs), should use `veaury/vite/esm` +// If the configuration file of vite has a `.js` suffix(vite.config.js), it is recommended to import it in the following way. +import veauryVitePlugins from 'veaury/vite' export default defineConfig({ plugins: [ diff --git a/README_zhcn.md b/README_zhcn.md index 6528cd3..e7ad992 100644 --- a/README_zhcn.md +++ b/README_zhcn.md @@ -94,8 +94,10 @@ $ npm i veaury -S ```js import { defineConfig } from 'vite' -// 如果是cjs模式,使用 'veaury/vite/cjs' -import veauryVitePlugins from 'veaury/vite/esm' +// 如果是commonjs模式(vite.config.cjs), 使用 `veaury/vite/cjs` 引入 +// 如果是esmodule模式(vite.config.mjs), 使用 `veaury/vite/esm` 引入 +// 如果vite的配置文件是`.js`后缀名(vite.config.js), 推荐使用如下的方式引入. +import veauryVitePlugins from 'veaury/vite' export default defineConfig({ plugins: [ @@ -113,8 +115,10 @@ export default defineConfig({ ```js import { defineConfig } from 'vite' -// 如果是cjs模式,使用 'veaury/vite/cjs' -import veauryVitePlugins from 'veaury/vite/esm' +// 如果是commonjs模式(vite.config.cjs), 使用 `veaury/vite/cjs` 引入 +// 如果是esmodule模式(vite.config.mjs), 使用 `veaury/vite/esm` 引入 +// 如果vite的配置文件是`.js`后缀名(vite.config.js), 推荐使用如下的方式引入. +import veauryVitePlugins from 'veaury/vite' export default defineConfig({ plugins: [ @@ -132,8 +136,10 @@ export default defineConfig({ ```js import { defineConfig } from 'vite' -// 如果是cjs模式,使用 'veaury/vite/cjs' -import veauryVitePlugins from 'veaury/vite/esm' +// 如果是commonjs模式(vite.config.cjs), 使用 `veaury/vite/cjs` 引入 +// 如果是esmodule模式(vite.config.mjs), 使用 `veaury/vite/esm` 引入 +// 如果vite的配置文件是`.js`后缀名(vite.config.js), 推荐使用如下的方式引入. +import veauryVitePlugins from 'veaury/vite' export default defineConfig({ plugins: [ From 1e5814158d2739982e09a1ebeb119a1141c9fbb5 Mon Sep 17 00:00:00 2001 From: devilwjp <9700616@qq.com> Date: Sat, 14 Sep 2024 16:22:14 +0800 Subject: [PATCH 3/3] 2.4.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e31fea0..6155867 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "veaury", "private": false, - "version": "2.4.4", + "version": "2.4.5", "description": "Use React in Vue3 and Vue3 in React, And as perfect as possible!", "main": "dist/veaury.umd.js", "module": "dist/veaury.esm.js",