提交 fa5b7b4b 编写于 作者: Q qiang

fix: event use costomDataset

上级 a5d93f2d
......@@ -38,7 +38,7 @@ export function requestComponentObserver(
boundingClientRect: normalizeRect(entrie.boundingClientRect),
relativeRect: normalizeRect(entrie.rootBounds!),
time: Date.now(),
// dataset: normalizeDataset(entrie.target),
// dataset: getCostomDataset(entrie.target),
// id: entrie.target.id,
})
})
......
......@@ -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__) {
......
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, invokeArrayFns, 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, initCostomDataset, 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__) {
......
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
......
......@@ -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: normalizeDataset(el),
dataset: getCostomDataset(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;
......
......@@ -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;
};
......
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: normalizeDataset(el),
dataset: getCostomDataset(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, getEnvLocale, 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, getCostomDataset, getEnvLocale, getLen, initCostomDataset, invokeArrayFns, isBuiltInComponent, isCustomElement, isNativeTag, normalizeDataset, normalizeTarget, once, parseQuery, passive, plusReady, removeLeadingSlash, sanitise, scrollTo, stringifyQuery, updateElementStyle };
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: normalizeDataset(el),
dataset: getCostomDataset(el),
offsetTop,
offsetLeft,
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册