@tarojs/runtime 3.6.33 → 3.6.35-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dom/event.js +5 -4
- package/dist/dom/event.js.map +1 -1
- package/dist/dom-external/inner-html/parser.js +44 -3
- package/dist/dom-external/inner-html/parser.js.map +1 -1
- package/dist/dom-external/inner-html/tags.d.ts +6 -1
- package/dist/dom-external/inner-html/tags.js +18 -3
- package/dist/dom-external/inner-html/tags.js.map +1 -1
- package/dist/index.cjs.js +64 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/runtime.esm.js +64 -7
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/runtime.esm.js
CHANGED
|
@@ -2104,15 +2104,30 @@ const specialMiniElements = {
|
|
|
2104
2104
|
img: 'image',
|
|
2105
2105
|
iframe: 'web-view'
|
|
2106
2106
|
};
|
|
2107
|
+
const specialElements = new Map([
|
|
2108
|
+
['a', {
|
|
2109
|
+
mapName(props) {
|
|
2110
|
+
if (props.as && isString(props.as))
|
|
2111
|
+
return props.as.toLowerCase();
|
|
2112
|
+
return !props.href || isString(props.href) && (/^javascript/.test(props.href)) ? 'view' : 'navigator';
|
|
2113
|
+
}
|
|
2114
|
+
}],
|
|
2115
|
+
]);
|
|
2116
|
+
const getSpecialElementMapping = (tag, expectsLowerCase = true) => {
|
|
2117
|
+
tag = expectsLowerCase ? tag.toLowerCase() : tag;
|
|
2118
|
+
return specialElements.get(tag);
|
|
2119
|
+
};
|
|
2107
2120
|
const internalCompsList = Object.keys(internalComponents)
|
|
2108
2121
|
.map(i => i.toLowerCase())
|
|
2109
2122
|
.join(',');
|
|
2110
2123
|
// https://developers.weixin.qq.com/miniprogram/dev/component
|
|
2111
2124
|
const isMiniElements = makeMap(internalCompsList, true);
|
|
2112
2125
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
|
|
2113
|
-
const isInlineElements = makeMap('
|
|
2126
|
+
const isInlineElements = makeMap('i,abbr,iframe,select,acronym,slot,small,span,bdi,kbd,strong,big,map,sub,sup,br,mark,mark,meter,template,canvas,textarea,cite,object,time,code,output,u,data,picture,tt,datalist,var,dfn,del,q,em,s,embed,samp,b', true);
|
|
2114
2127
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
|
|
2115
2128
|
const isBlockElements = makeMap('address,fieldset,li,article,figcaption,main,aside,figure,nav,blockquote,footer,ol,details,form,p,dialog,h1,h2,h3,h4,h5,h6,pre,dd,header,section,div,hgroup,table,dl,hr,ul,dt', true);
|
|
2129
|
+
// specialElements
|
|
2130
|
+
const isSpecialElements = makeMap('a', true);
|
|
2116
2131
|
|
|
2117
2132
|
const closingTagAncestorBreakers = {
|
|
2118
2133
|
li: ['ul', 'ol', 'menu'],
|
|
@@ -2141,7 +2156,21 @@ function hasTerminalParent(tagName, stack) {
|
|
|
2141
2156
|
}
|
|
2142
2157
|
return false;
|
|
2143
2158
|
}
|
|
2144
|
-
|
|
2159
|
+
/**
|
|
2160
|
+
* 将属性数组转换为属性对象
|
|
2161
|
+
* @param attributes 字符串数组,包含属性信息
|
|
2162
|
+
* @returns 属性对象,键为属性名,值为属性值或true
|
|
2163
|
+
*/
|
|
2164
|
+
function attributesArray2Props(attributes) {
|
|
2165
|
+
const props = {};
|
|
2166
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
2167
|
+
const attr = attributes[i];
|
|
2168
|
+
const [key, value] = splitEqual(attr);
|
|
2169
|
+
props[key] = value == null ? true : unquote(value);
|
|
2170
|
+
}
|
|
2171
|
+
return props;
|
|
2172
|
+
}
|
|
2173
|
+
function getTagName(tag, attributes) {
|
|
2145
2174
|
if (options.html.renderHTMLTag) {
|
|
2146
2175
|
return tag;
|
|
2147
2176
|
}
|
|
@@ -2157,6 +2186,14 @@ function getTagName(tag) {
|
|
|
2157
2186
|
else if (isInlineElements(tag)) {
|
|
2158
2187
|
return 'text';
|
|
2159
2188
|
}
|
|
2189
|
+
else if (isSpecialElements(tag)) {
|
|
2190
|
+
// if it's special tag, the real tag is determined by the config mapping
|
|
2191
|
+
const mapping = getSpecialElementMapping(tag);
|
|
2192
|
+
const props = attributesArray2Props(attributes);
|
|
2193
|
+
if (mapping) {
|
|
2194
|
+
return mapping.mapName(props);
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2160
2197
|
return 'view';
|
|
2161
2198
|
}
|
|
2162
2199
|
function splitEqual(str) {
|
|
@@ -2190,7 +2227,26 @@ function format(children, document, styleOptions, parent) {
|
|
|
2190
2227
|
parent === null || parent === void 0 ? void 0 : parent.appendChild(text);
|
|
2191
2228
|
return text;
|
|
2192
2229
|
}
|
|
2193
|
-
|
|
2230
|
+
// img标签,把width和height写入style,删除原有的width、height和style属性
|
|
2231
|
+
if (child.tagName === 'img') {
|
|
2232
|
+
let styleText = '';
|
|
2233
|
+
const toBeRemovedIndexs = [];
|
|
2234
|
+
for (let i = 0; i < child.attributes.length; i++) {
|
|
2235
|
+
const attr = child.attributes[i];
|
|
2236
|
+
const [key, value] = splitEqual(attr);
|
|
2237
|
+
if (key === 'width' || key === 'height') {
|
|
2238
|
+
styleText += `${key}:${value};`;
|
|
2239
|
+
toBeRemovedIndexs.push(i);
|
|
2240
|
+
}
|
|
2241
|
+
else if (key === 'style') {
|
|
2242
|
+
styleText = `${styleText}${value};`;
|
|
2243
|
+
toBeRemovedIndexs.push(i);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
child.attributes = child.attributes.filter((_, index) => !toBeRemovedIndexs.includes(index));
|
|
2247
|
+
child.attributes.push(`style=${styleText.replace(/['"]/g, '')}`);
|
|
2248
|
+
}
|
|
2249
|
+
const el = document.createElement(getTagName(child.tagName, child.attributes));
|
|
2194
2250
|
el.h5tagName = child.tagName;
|
|
2195
2251
|
parent === null || parent === void 0 ? void 0 : parent.appendChild(el);
|
|
2196
2252
|
if (!options.html.renderHTMLTag) {
|
|
@@ -2496,14 +2552,15 @@ class TaroEvent {
|
|
|
2496
2552
|
this.defaultPrevented = true;
|
|
2497
2553
|
}
|
|
2498
2554
|
get target() {
|
|
2499
|
-
var _a, _b, _c, _d;
|
|
2555
|
+
var _a, _b, _c, _d, _e;
|
|
2500
2556
|
const cacheTarget = this.cacheTarget;
|
|
2501
2557
|
if (!cacheTarget) {
|
|
2502
2558
|
const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
|
|
2559
|
+
const currentEle = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b.sid) || target.id || null);
|
|
2503
2560
|
// Note:优先判断冒泡场景alipay的targetDataset的sid, 不然冒泡场景target属性吐出不对,其余拿取当前绑定id
|
|
2504
|
-
const element = env.document.getElementById(((
|
|
2505
|
-
target.dataset = element !== null ? element.dataset : EMPTY_OBJ;
|
|
2506
|
-
for (const key in (
|
|
2561
|
+
const element = env.document.getElementById(((_c = target.targetDataset) === null || _c === void 0 ? void 0 : _c.sid) || ((_d = target.dataset) === null || _d === void 0 ? void 0 : _d.sid) || target.id || null);
|
|
2562
|
+
target.dataset = Object.assign(Object.assign({}, (currentEle !== null ? currentEle.dataset : EMPTY_OBJ)), (element !== null ? element.dataset : EMPTY_OBJ));
|
|
2563
|
+
for (const key in (_e = this.mpEvent) === null || _e === void 0 ? void 0 : _e.detail) {
|
|
2507
2564
|
target[key] = this.mpEvent.detail[key];
|
|
2508
2565
|
}
|
|
2509
2566
|
this.cacheTarget = target;
|