Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
fa5b7b4b
U
uni-app
项目概览
小浣熊撸代码
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fa5b7b4b
编写于
5月 19, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: event use costomDataset
上级
a5d93f2d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
80 addition
and
36 deletion
+80
-36
packages/uni-api/src/helpers/requestComponentObserver.ts
packages/uni-api/src/helpers/requestComponentObserver.ts
+1
-1
packages/uni-core/src/view/plugin/index.ts
packages/uni-core/src/view/plugin/index.ts
+1
-2
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+2
-26
packages/uni-h5/src/service/api/ui/requestComponentInfo.ts
packages/uni-h5/src/service/api/ui/requestComponentInfo.ts
+2
-1
packages/uni-shared/dist/uni-shared.cjs.js
packages/uni-shared/dist/uni-shared.cjs.js
+31
-1
packages/uni-shared/dist/uni-shared.d.ts
packages/uni-shared/dist/uni-shared.d.ts
+9
-1
packages/uni-shared/dist/uni-shared.es.js
packages/uni-shared/dist/uni-shared.es.js
+31
-3
packages/uni-shared/src/dom/costomDataset.ts
packages/uni-shared/src/dom/costomDataset.ts
+0
-0
packages/uni-shared/src/dom/index.ts
packages/uni-shared/src/dom/index.ts
+3
-1
未找到文件。
packages/uni-api/src/helpers/requestComponentObserver.ts
浏览文件 @
fa5b7b4b
...
...
@@ -38,7 +38,7 @@ export function requestComponentObserver(
boundingClientRect
:
normalizeRect
(
entrie
.
boundingClientRect
),
relativeRect
:
normalizeRect
(
entrie
.
rootBounds
!
),
time
:
Date
.
now
(),
// dataset:
normalize
Dataset(entrie.target),
// dataset:
getCostom
Dataset(entrie.target),
// id: entrie.target.id,
})
})
...
...
packages/uni-core/src/view/plugin/index.ts
浏览文件 @
fa5b7b4b
...
...
@@ -2,8 +2,7 @@ import { App } from 'vue'
import
{
initLongPress
}
from
'
./longPress
'
import
{
initAppConfig
}
from
'
./appConfig
'
import
{
initCostomDataset
}
from
'
./costomDataset
'
export
{
getCostomDataset
}
from
'
./costomDataset
'
import
{
initCostomDataset
}
from
'
@dcloudio/uni-shared
'
export
function
initView
(
app
:
App
)
{
if
(
__NODE_JS__
)
{
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
fa5b7b4b
import {isFunction, extend, hyphenate, isPlainObject,
camelize,
isString, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1} from "@vue/shared";
import {isFunction, extend, hyphenate, isPlainObject, isString, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1} from "@vue/shared";
import {injectHook, withModifiers, createVNode, getCurrentInstance, inject, provide, reactive, openBlock, createBlock, mergeProps, toDisplayString, defineComponent, ref, watch, onActivated, onMounted, nextTick, resolveComponent, toHandlers, renderSlot, onUnmounted, computed, onBeforeUnmount, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createCommentVNode, createTextVNode, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, Teleport, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent} from "vue";
import {once, passive, normalizeTarget, isBuiltInComponent, in
vokeArrayFns, NAVBAR_HEIGHT, parseQuery, PRIMARY_COLOR, debounce
, callOptions, removeLeadingSlash, getLen, ON_REACH_BOTTOM_DISTANCE, decodedQuery, updateElementStyle, addFont, scrollTo, formatDateTime} from "@dcloudio/uni-shared";
import {once, passive, normalizeTarget, isBuiltInComponent, in
itCostomDataset, invokeArrayFns, NAVBAR_HEIGHT, parseQuery, PRIMARY_COLOR, debounce, getCostomDataset
, callOptions, removeLeadingSlash, getLen, ON_REACH_BOTTOM_DISTANCE, decodedQuery, updateElementStyle, addFont, scrollTo, formatDateTime} from "@dcloudio/uni-shared";
import {initVueI18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT} from "@dcloudio/uni-i18n";
import {useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView} from "vue-router";
function applyOptions(options, instance2, publicThis) {
...
...
@@ -959,30 +959,6 @@ function initAppConfig$1(appConfig) {
globalProperties.$gcd = getComponentDescriptor;
}
}
function formatKey(key) {
return camelize(key.substring(5));
}
function initCostomDataset() {
const prototype = HTMLElement.prototype;
const setAttribute = prototype.setAttribute;
prototype.setAttribute = function(key, value) {
if (key.startsWith("data-") && this.tagName.startsWith("UNI-")) {
const dataset = this.__uniDataset = this.__uniDataset || {};
dataset[formatKey(key)] = value;
}
setAttribute.call(this, key, value);
};
const removeAttribute = prototype.removeAttribute;
prototype.removeAttribute = function(key) {
if (this.__uniDataset && key.startsWith("data-") && this.tagName.startsWith("UNI-")) {
delete this.__uniDataset[formatKey(key)];
}
removeAttribute.call(this, key);
};
}
function getCostomDataset(el) {
return Object.assign({}, el.dataset, el.__uniDataset);
}
function initView(app) {
initCostomDataset();
if (__UNI_FEATURE_LONGPRESS__) {
...
...
packages/uni-h5/src/service/api/ui/requestComponentInfo.ts
浏览文件 @
fa5b7b4b
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
getWindowOffset
,
getCostomDataset
}
from
'
@dcloudio/uni-core
'
import
{
getCostomDataset
}
from
'
@dcloudio/uni-shared
'
import
{
getWindowOffset
}
from
'
@dcloudio/uni-core
'
import
{
getContextInfo
}
from
'
@dcloudio/uni-components
'
type
NodeField
=
UniApp
.
NodeField
...
...
packages/uni-shared/dist/uni-shared.cjs.js
浏览文件 @
fa5b7b4b
...
...
@@ -4,6 +4,34 @@ Object.defineProperty(exports, '__esModule', { value: true });
var
shared
=
require
(
'
@vue/shared
'
);
function
formatKey
(
key
)
{
return
shared
.
camelize
(
key
.
substring
(
5
));
}
function
initCostomDataset
()
{
const
prototype
=
HTMLElement
.
prototype
;
const
setAttribute
=
prototype
.
setAttribute
;
prototype
.
setAttribute
=
function
(
key
,
value
)
{
if
(
key
.
startsWith
(
'
data-
'
)
&&
this
.
tagName
.
startsWith
(
'
UNI-
'
))
{
const
dataset
=
(
this
.
__uniDataset
=
this
.
__uniDataset
||
{});
dataset
[
formatKey
(
key
)]
=
value
;
}
setAttribute
.
call
(
this
,
key
,
value
);
};
const
removeAttribute
=
prototype
.
removeAttribute
;
prototype
.
removeAttribute
=
function
(
key
)
{
if
(
this
.
__uniDataset
&&
key
.
startsWith
(
'
data-
'
)
&&
this
.
tagName
.
startsWith
(
'
UNI-
'
))
{
delete
this
.
__uniDataset
[
formatKey
(
key
)];
}
removeAttribute
.
call
(
this
,
key
);
};
}
function
getCostomDataset
(
el
)
{
return
Object
.
assign
({},
el
.
dataset
,
el
.
__uniDataset
);
}
const
unitRE
=
new
RegExp
(
`"[^"]+"|'[^']+'|url\\([^)]+\\)|(\\d*\\.?\\d+)[r|u]px`
,
'
g
'
);
function
toFixed
(
number
,
precision
)
{
const
multiplier
=
Math
.
pow
(
10
,
precision
+
1
);
...
...
@@ -36,7 +64,7 @@ function normalizeTarget(el) {
const
{
id
,
offsetTop
,
offsetLeft
}
=
el
;
return
{
id
,
dataset
:
normalize
Dataset
(
el
),
dataset
:
getCostom
Dataset
(
el
),
offsetTop
,
offsetLeft
,
};
...
...
@@ -386,8 +414,10 @@ exports.decode = decode;
exports
.
decodedQuery
=
decodedQuery
;
exports
.
defaultRpx2Unit
=
defaultRpx2Unit
;
exports
.
formatDateTime
=
formatDateTime
;
exports
.
getCostomDataset
=
getCostomDataset
;
exports
.
getEnvLocale
=
getEnvLocale
;
exports
.
getLen
=
getLen
;
exports
.
initCostomDataset
=
initCostomDataset
;
exports
.
invokeArrayFns
=
invokeArrayFns
;
exports
.
isBuiltInComponent
=
isBuiltInComponent
;
exports
.
isCustomElement
=
isCustomElement
;
...
...
packages/uni-shared/dist/uni-shared.d.ts
浏览文件 @
fa5b7b4b
...
...
@@ -46,10 +46,18 @@ export declare function formatDateTime({ date, mode }: {
mode
?:
string
|
undefined
;
}):
string
;
export
declare
function
getCostomDataset
(
el
:
HTMLElement
|
HTMLElementWithDataset
):
DOMStringMap
&
Record
<
string
,
any
>
;
export
declare
function
getEnvLocale
():
string
;
export
declare
function
getLen
(
str
?:
string
):
number
;
declare
interface
HTMLElementWithDataset
extends
HTMLElement
{
__uniDataset
?:
Record
<
string
,
any
>
;
}
export
declare
function
initCostomDataset
():
void
;
export
declare
const
invokeArrayFns
:
(
fns
:
Function
[],
arg
?:
any
)
=>
any
;
export
declare
function
isBuiltInComponent
(
tag
:
string
):
boolean
;
...
...
@@ -64,7 +72,7 @@ export declare function normalizeDataset(el: Element): any;
export
declare
function
normalizeTarget
(
el
:
HTMLElement
):
{
id
:
string
;
dataset
:
any
;
dataset
:
DOMStringMap
&
Record
<
string
,
any
>
;
offsetTop
:
number
;
offsetLeft
:
number
;
};
...
...
packages/uni-shared/dist/uni-shared.es.js
浏览文件 @
fa5b7b4b
import
{
isString
,
isHTMLTag
,
isSVGTag
,
isPlainObject
,
isArray
}
from
'
@vue/shared
'
;
import
{
camelize
,
isString
,
isHTMLTag
,
isSVGTag
,
isPlainObject
,
isArray
}
from
'
@vue/shared
'
;
function
formatKey
(
key
)
{
return
camelize
(
key
.
substring
(
5
));
}
function
initCostomDataset
()
{
const
prototype
=
HTMLElement
.
prototype
;
const
setAttribute
=
prototype
.
setAttribute
;
prototype
.
setAttribute
=
function
(
key
,
value
)
{
if
(
key
.
startsWith
(
'
data-
'
)
&&
this
.
tagName
.
startsWith
(
'
UNI-
'
))
{
const
dataset
=
(
this
.
__uniDataset
=
this
.
__uniDataset
||
{});
dataset
[
formatKey
(
key
)]
=
value
;
}
setAttribute
.
call
(
this
,
key
,
value
);
};
const
removeAttribute
=
prototype
.
removeAttribute
;
prototype
.
removeAttribute
=
function
(
key
)
{
if
(
this
.
__uniDataset
&&
key
.
startsWith
(
'
data-
'
)
&&
this
.
tagName
.
startsWith
(
'
UNI-
'
))
{
delete
this
.
__uniDataset
[
formatKey
(
key
)];
}
removeAttribute
.
call
(
this
,
key
);
};
}
function
getCostomDataset
(
el
)
{
return
Object
.
assign
({},
el
.
dataset
,
el
.
__uniDataset
);
}
const
unitRE
=
new
RegExp
(
`"[^"]+"|'[^']+'|url\\([^)]+\\)|(\\d*\\.?\\d+)[r|u]px`
,
'
g
'
);
function
toFixed
(
number
,
precision
)
{
...
...
@@ -32,7 +60,7 @@ function normalizeTarget(el) {
const
{
id
,
offsetTop
,
offsetLeft
}
=
el
;
return
{
id
,
dataset
:
normalize
Dataset
(
el
),
dataset
:
getCostom
Dataset
(
el
),
offsetTop
,
offsetLeft
,
};
...
...
@@ -359,4 +387,4 @@ function getEnvLocale() {
return
(
lang
&&
lang
.
replace
(
/
[
.:
]
.*/
,
''
))
||
'
en
'
;
}
export
{
BUILT_IN_TAGS
,
COMPONENT_NAME_PREFIX
,
COMPONENT_PREFIX
,
COMPONENT_SELECTOR_PREFIX
,
NAVBAR_HEIGHT
,
ON_REACH_BOTTOM_DISTANCE
,
PLUS_RE
,
PRIMARY_COLOR
,
RESPONSIVE_MIN_WIDTH
,
TABBAR_HEIGHT
,
TAGS
,
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_GLOBAL_DATA
,
UNI_SSR_STORE
,
addFont
,
callOptions
,
createRpx2Unit
,
debounce
,
decode
,
decodedQuery
,
defaultRpx2Unit
,
formatDateTime
,
get
EnvLocale
,
getLen
,
invokeArrayFns
,
isBuiltInComponent
,
isCustomElement
,
isNativeTag
,
normalizeDataset
,
normalizeTarget
,
once
,
parseQuery
,
passive
,
plusReady
,
removeLeadingSlash
,
sanitise
,
scrollTo
,
stringifyQuery
,
updateElementStyle
};
export
{
BUILT_IN_TAGS
,
COMPONENT_NAME_PREFIX
,
COMPONENT_PREFIX
,
COMPONENT_SELECTOR_PREFIX
,
NAVBAR_HEIGHT
,
ON_REACH_BOTTOM_DISTANCE
,
PLUS_RE
,
PRIMARY_COLOR
,
RESPONSIVE_MIN_WIDTH
,
TABBAR_HEIGHT
,
TAGS
,
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_GLOBAL_DATA
,
UNI_SSR_STORE
,
addFont
,
callOptions
,
createRpx2Unit
,
debounce
,
decode
,
decodedQuery
,
defaultRpx2Unit
,
formatDateTime
,
get
CostomDataset
,
getEnvLocale
,
getLen
,
initCostomDataset
,
invokeArrayFns
,
isBuiltInComponent
,
isCustomElement
,
isNativeTag
,
normalizeDataset
,
normalizeTarget
,
once
,
parseQuery
,
passive
,
plusReady
,
removeLeadingSlash
,
sanitise
,
scrollTo
,
stringifyQuery
,
updateElementStyle
};
packages/uni-
core/src/view/plugin
/costomDataset.ts
→
packages/uni-
shared/src/dom
/costomDataset.ts
浏览文件 @
fa5b7b4b
文件已移动
packages/uni-shared/src/dom/index.ts
浏览文件 @
fa5b7b4b
import
{
FontFaceDescriptors
}
from
'
css-font-loading-module
'
import
{
isString
}
from
'
@vue/shared
'
import
{
getCostomDataset
}
from
'
./costomDataset
'
export
{
initCostomDataset
,
getCostomDataset
}
from
'
./costomDataset
'
export
*
from
'
./style
'
...
...
@@ -16,7 +18,7 @@ export function normalizeTarget(el: HTMLElement) {
const
{
id
,
offsetTop
,
offsetLeft
}
=
el
return
{
id
,
dataset
:
normalize
Dataset
(
el
),
dataset
:
getCostom
Dataset
(
el
),
offsetTop
,
offsetLeft
,
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录