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

@erickmerchant/framework

Package Overview
Dependencies
Maintainers
1
Versions
244
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@erickmerchant/framework - npm Package Compare versions

Comparing version 44.0.0 to 44.1.0

149

create-dom-view.js

@@ -34,3 +34,3 @@ import {tokenTypes} from './html.js'

const morphAttribute = (target, key, value, isExistingElement) => {
const remove = value == null || value === false
const remove = isExistingElement && value == null

@@ -55,79 +55,13 @@ if (key.charAt(0) === '@') {

}
} else {
if (isExistingElement && remove) {
target.removeAttribute(key)
} else if (!remove) {
const stringified =
value === true ? '' : typeof value === 'string' ? value : String(value)
if (!isExistingElement || target.getAttribute(key) !== stringified) {
target.setAttribute(key, stringified)
}
} else if (remove) {
target.removeAttribute(key)
} else if (value === true || value === false || key === 'value') {
if (target[key] !== value) {
target[key] = value
}
if (value === true || value === false || key === 'value') {
if (target[key] !== value) {
target[key] = value
}
}
} else if (value != null && target.getAttribute(key) !== value) {
target.setAttribute(key, value)
}
}
const morphChild = (
target,
childNode,
next,
variables,
isExistingElement,
isSameView
) => {
const document = target.ownerDocument
let mode = !isExistingElement || childNode == null ? 2 : !isSameView ? 1 : 0
let currentChild = childNode
if (next.type === tokenTypes.text) {
if (!mode && childNode.nodeType !== 3) {
mode = 1
}
if (mode) {
currentChild = document.createTextNode(next.value)
} else if (childNode.data !== next.value) {
childNode.data = next.value
}
} else {
if (
!mode &&
(childNode.nodeType !== 1 ||
childNode.nodeName.toLowerCase() !== next.tag)
) {
mode = 1
}
if (mode) {
const isSvg = next.tag === 'svg' || target.namespaceURI === svgNamespace
currentChild = isSvg
? document.createElementNS(svgNamespace, next.tag)
: document.createElement(next.tag)
}
if (next.view) {
morphRoot(currentChild, next, !mode)
} else if (mode || next.dynamic) {
morph(currentChild, next, variables, !mode, isSameView)
}
}
if (mode === 2) {
target.appendChild(currentChild)
} else if (mode === 1) {
target.replaceChild(currentChild, childNode)
}
return getNextSibling(currentChild)
}
const morph = (target, next, variables, isExistingElement, isSameView) => {

@@ -185,7 +119,5 @@ let attributeIndex = 0

child = variables[child.value]
}
if (!Array.isArray(child)) {
child = [child]
}
} else {
if (!Array.isArray(child)) {
child = [child]

@@ -195,16 +127,55 @@ }

for (let i = 0; i < child.length; i++) {
let grand = child[i]
const next = child[i]
if (!grand?.type) {
grand = {type: tokenTypes.text, value: grand ?? ''}
const document = target.ownerDocument
let mode =
!isExistingElement || childNode == null ? 2 : !isSameView ? 1 : 0
let currentChild = childNode
if (!next?.type || next.type === tokenTypes.text) {
if (!mode && childNode.nodeType !== 3) {
mode = 1
}
const value = next?.value ?? next ?? ''
if (mode) {
currentChild = document.createTextNode(value)
} else if (childNode.data !== value) {
childNode.data = value
}
} else {
if (
!mode &&
(childNode.nodeType !== 1 ||
childNode.nodeName.toLowerCase() !== next.tag)
) {
mode = 1
}
if (mode) {
const isSvg =
next.tag === 'svg' || target.namespaceURI === svgNamespace
currentChild = isSvg
? document.createElementNS(svgNamespace, next.tag)
: document.createElement(next.tag)
}
if (next.view) {
morphRoot(currentChild, next, !mode)
} else if (mode || next.dynamic) {
morph(currentChild, next, variables, !mode, isSameView)
}
}
childNode = morphChild(
target,
childNode,
grand,
variables,
isExistingElement,
isSameView
)
if (mode === 2) {
target.appendChild(currentChild)
} else if (mode === 1) {
target.replaceChild(currentChild, childNode)
}
childNode = getNextSibling(currentChild)
}

@@ -211,0 +182,0 @@ }

{
"name": "@erickmerchant/framework",
"version": "44.0.0",
"version": "44.1.0",
"description": "A front-end framework.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/erickmerchant/framework#readme",

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