Socket
Socket
Sign inDemoInstall

hastscript

Package Overview
Dependencies
6
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.1 to 7.0.2

6

lib/core.d.ts

@@ -13,3 +13,7 @@ /**

(selector: null | undefined, ...children: HChild[]): Root
(selector: string, properties: HProperties, ...children: HChild[]): Element
(
selector: string,
properties?: HProperties | undefined,
...children: HChild[]
): Element
(selector: string, ...children: HChild[]): Element

@@ -16,0 +20,0 @@ }

51

lib/core.js

@@ -28,5 +28,5 @@ /**

var buttonTypes = new Set(['menu', 'submit', 'reset', 'button'])
const buttonTypes = new Set(['menu', 'submit', 'reset', 'button'])
var own = {}.hasOwnProperty
const own = {}.hasOwnProperty

@@ -39,3 +39,3 @@ /**

export function core(schema, defaultTagName, caseSensitive) {
var adjust = caseSensitive && createAdjustMap(caseSensitive)
const adjust = caseSensitive && createAdjustMap(caseSensitive)

@@ -47,3 +47,3 @@ const h =

* (selector: null|undefined, ...children: HChild[]): Root
* (selector: string, properties: HProperties, ...children: HChild[]): Element
* (selector: string, properties?: HProperties, ...children: HChild[]): Element
* (selector: string, ...children: HChild[]): Element

@@ -62,11 +62,9 @@ * }}

function (selector, properties, ...children) {
var index = -1
let index = -1
/** @type {HResult} */
var node
/** @type {string} */
var key
let node
if (selector === undefined || selector === null) {
node = {type: 'root', children: []}
// @ts-ignore Properties are not supported for roots.
// @ts-expect-error Properties are not supported for roots.
children.unshift(properties)

@@ -83,5 +81,8 @@ } else {

if (isProperties(properties, node.tagName)) {
/** @type {string} */
let key
for (key in properties) {
if (own.call(properties, key)) {
// @ts-ignore `node.properties` is set.
// @ts-expect-error `node.properties` is set.
addProperty(schema, node.properties, key, properties[key])

@@ -100,3 +101,3 @@ }

if (node.tagName === 'template') {
if (node.type === 'element' && node.tagName === 'template') {
node.content = {type: 'root', children: node.children}

@@ -132,3 +133,3 @@ node.children = []

if (Array.isArray(value.children)) {
if ('children' in value && Array.isArray(value.children)) {
return false

@@ -152,8 +153,6 @@ }

function addProperty(schema, properties, key, value) {
var info = find(schema, key)
var index = -1
const info = find(schema, key)
let index = -1
/** @type {HPropertyValue} */
var result
/** @type {Array.<string|number>} */
var finalResult
let result

@@ -191,6 +190,7 @@ // Ignore nullish and NaN values.

if (Array.isArray(result)) {
finalResult = []
/** @type {Array.<string|number>} */
const finalResult = []
while (++index < result.length) {
// @ts-ignore Assume no booleans in array.
// @ts-expect-error Assume no booleans in array.
finalResult[index] = parsePrimitive(info, info.property, result[index])

@@ -204,3 +204,3 @@ }

if (info.property === 'className' && Array.isArray(properties.className)) {
// @ts-ignore Assume no booleans in `className`.
// @ts-expect-error Assume no booleans in `className`.
result = properties.className.concat(result)

@@ -218,3 +218,3 @@ }

function addChild(nodes, value) {
var index = -1
let index = -1

@@ -231,3 +231,2 @@ if (value === undefined || value === null) {

if (value.type === 'root') {
// @ts-ignore it looks like a root, TS…
addChild(nodes, value.children)

@@ -273,5 +272,5 @@ } else {

/** @type {Array.<string>} */
var result = []
const result = []
/** @type {string} */
var key
let key

@@ -293,4 +292,4 @@ for (key in value) {

/** @type {Object.<string, string>} */
var result = {}
var index = -1
const result = {}
let index = -1

@@ -297,0 +296,0 @@ while (++index < values.length) {

@@ -9,3 +9,3 @@ export const h: {

selector: string,
properties: import('./core.js').HProperties,
properties?: import('./core.js').HProperties | undefined,
...children: import('./core.js').HChild[]

@@ -23,3 +23,4 @@ ): import('hast').Element

type IntrinsicElements = import('./jsx-classic').IntrinsicElements
type ElementChildrenAttribute = import('./jsx-classic').ElementChildrenAttribute
type ElementChildrenAttribute =
import('./jsx-classic').ElementChildrenAttribute
}

@@ -26,0 +27,0 @@ }

// Export `JSX` as a global for TypeScript.
export * from './jsx-automatic.js'
import {runtime} from './runtime.js'
import {h} from './html.js'
export * from './jsx-automatic.js'
export const {Fragment, jsx, jsxs} = runtime(h)
// Export `JSX` as a global for TypeScript.
export * from './jsx-automatic.js'
import {runtime} from './runtime.js'
import {s} from './svg.js'
export * from './jsx-automatic.js'
export const {Fragment, jsx, jsxs} = runtime(s)

@@ -16,5 +16,3 @@ /**

*/
export function runtime(
f: ReturnType<Core>
): {
export function runtime(f: ReturnType<Core>): {
Fragment: null

@@ -21,0 +19,0 @@ jsx: {

@@ -32,3 +32,3 @@ /**

function (type, props) {
var {children, ...properties} = props
const {children, ...properties} = props
return type === null ? f(type, children) : f(type, properties, children)

@@ -35,0 +35,0 @@ }

@@ -9,3 +9,3 @@ export const s: {

selector: string,
properties: import('./core.js').HProperties,
properties?: import('./core.js').HProperties | undefined,
...children: import('./core.js').HChild[]

@@ -23,3 +23,4 @@ ): import('hast').Element

type IntrinsicElements = import('./jsx-classic').IntrinsicElements
type ElementChildrenAttribute = import('./jsx-classic').ElementChildrenAttribute
type ElementChildrenAttribute =
import('./jsx-classic').ElementChildrenAttribute
}

@@ -26,0 +27,0 @@ }

{
"name": "hastscript",
"version": "7.0.1",
"version": "7.0.2",
"description": "hast utility to create trees",

@@ -80,7 +80,7 @@ "license": "MIT",

"tape": "^5.0.0",
"tsd": "^0.14.0",
"tsd": "^0.17.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"unist-builder": "^3.0.0",
"xo": "^0.39.0"
"xo": "^0.42.0"
},

@@ -105,7 +105,3 @@ "scripts": {

"xo": {
"prettier": true,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
"prettier": true
},

@@ -112,0 +108,0 @@ "remarkConfig": {

@@ -271,3 +271,3 @@ # hastscript

```js
var tree = {type: 'root', children: []}
const tree = {type: 'root', children: []}

@@ -287,7 +287,7 @@ tree.children.push(h('script', 'alert(1)'))

```js
var tree = {type: 'root', children: []}
const tree = {type: 'root', children: []}
// Somehow someone injected these properties instead of an expected `src` and
// `alt`:
var otherProps = {src: 'x', onError: 'alert(2)'}
const otherProps = {src: 'x', onError: 'alert(2)'}

@@ -307,6 +307,6 @@ tree.children.push(h('img', {src: 'default.png', ...otherProps}))

```js
var tree = {type: 'root', children: []}
const tree = {type: 'root', children: []}
// Somehow this isn’t the expected `'wooorm'`.
var username = {
const username = {
type: 'element',

@@ -313,0 +313,0 @@ tagName: 'script',

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc