Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tarojs/runtime

Package Overview
Dependencies
Maintainers
0
Versions
650
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tarojs/runtime - npm Package Compare versions

Comparing version 3.6.35 to 3.6.36-alpha.1

47

dist/dom-external/inner-html/parser.js

@@ -5,3 +5,3 @@ import { isFunction } from '@tarojs/shared';

import StyleTagParser from './style.js';
import { specialMiniElements, isMiniElements, isBlockElements, isInlineElements } from './tags.js';
import { specialMiniElements, isMiniElements, isBlockElements, isInlineElements, isSpecialElements, getSpecialElementMapping } from './tags.js';
import { unquote } from './utils.js';

@@ -36,3 +36,17 @@

}
function getTagName(tag) {
/**
* 将属性数组转换为属性对象
* @param attributes 字符串数组,包含属性信息
* @returns 属性对象,键为属性名,值为属性值或true
*/
function attributesArray2Props(attributes) {
const props = {};
for (let i = 0; i < attributes.length; i++) {
const attr = attributes[i];
const [key, value] = splitEqual(attr);
props[key] = value == null ? true : unquote(value);
}
return props;
}
function getTagName(tag, attributes) {
if (options.html.renderHTMLTag) {

@@ -53,2 +67,10 @@ return tag;

}
else if (isSpecialElements(tag)) {
// if it's special tag, the real tag is determined by the config mapping
const mapping = getSpecialElementMapping(tag);
const props = attributesArray2Props(attributes);
if (mapping) {
return mapping.mapName(props);
}
}
return 'view';

@@ -87,3 +109,22 @@ }

}
const el = document.createElement(getTagName(child.tagName));
// img标签,把width和height写入style,删除原有的width、height和style属性
if (child.tagName === 'img') {
let styleText = '';
const toBeRemovedIndexs = [];
for (let i = 0; i < child.attributes.length; i++) {
const attr = child.attributes[i];
const [key, value] = splitEqual(attr);
if (key === 'width' || key === 'height') {
styleText += `${key}:${value};`;
toBeRemovedIndexs.push(i);
}
else if (key === 'style') {
styleText = `${styleText}${value};`;
toBeRemovedIndexs.push(i);
}
}
child.attributes = child.attributes.filter((_, index) => !toBeRemovedIndexs.includes(index));
child.attributes.push(`style=${styleText.replace(/['"]/g, '')}`);
}
const el = document.createElement(getTagName(child.tagName, child.attributes));
el.h5tagName = child.tagName;

@@ -90,0 +131,0 @@ parent === null || parent === void 0 ? void 0 : parent.appendChild(el);

@@ -6,5 +6,10 @@ declare function makeMap(str: string, expectsLowerCase?: boolean): (key: string) => boolean;

};
interface SpecialMap {
mapName: (props: Record<string, string | boolean>) => string;
}
declare const getSpecialElementMapping: (tag: string, expectsLowerCase?: boolean) => SpecialMap | undefined;
declare const isMiniElements: (key: string) => boolean;
declare const isInlineElements: (key: string) => boolean;
declare const isBlockElements: (key: string) => boolean;
export { makeMap, specialMiniElements, isMiniElements, isInlineElements, isBlockElements };
declare const isSpecialElements: (key: string) => boolean;
export { makeMap, specialMiniElements, getSpecialElementMapping, isMiniElements, isInlineElements, isBlockElements, isSpecialElements };

@@ -1,2 +0,2 @@

import { internalComponents } from '@tarojs/shared';
import { isString, internalComponents } from '@tarojs/shared';

@@ -15,2 +15,15 @@ function makeMap(str, expectsLowerCase) {

};
const specialElements = new Map([
['a', {
mapName(props) {
if (props.as && isString(props.as))
return props.as.toLowerCase();
return !props.href || isString(props.href) && (/^javascript/.test(props.href)) ? 'view' : 'navigator';
}
}],
]);
const getSpecialElementMapping = (tag, expectsLowerCase = true) => {
tag = expectsLowerCase ? tag.toLowerCase() : tag;
return specialElements.get(tag);
};
const internalCompsList = Object.keys(internalComponents)

@@ -22,7 +35,9 @@ .map(i => i.toLowerCase())

// https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
const isInlineElements = makeMap('a,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);
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);
// https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
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);
// specialElements
const isSpecialElements = makeMap('a', true);
export { isBlockElements, isInlineElements, isMiniElements, makeMap, specialMiniElements };
export { getSpecialElementMapping, isBlockElements, isInlineElements, isMiniElements, isSpecialElements, makeMap, specialMiniElements };
//# sourceMappingURL=tags.js.map

6

package.json
{
"name": "@tarojs/runtime",
"version": "3.6.35",
"version": "3.6.36-alpha.1",
"description": "taro runtime for mini apps.",

@@ -38,6 +38,6 @@ "browser": "dist/index.js",

"typescript": "^4.7.4",
"@tarojs/shared": "3.6.35"
"@tarojs/shared": "3.6.36-alpha.1"
},
"peerDependencies": {
"@tarojs/shared": "~3.6.35"
"@tarojs/shared": "~3.6.36-alpha.1"
},

@@ -44,0 +44,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc