fix: minor refactor to reduce code size

This commit is contained in:
Nolan Lawson 2024-03-09 15:35:45 -08:00
parent 15bca2197f
commit ff1326151b
2 changed files with 5 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import { getFromMap, parseTemplate, toString } from './utils.js'
const parseCache = new WeakMap()
const domInstancesCache = new WeakMap()
// This needs to be a symbol because it needs to be different from any possible output of a key function
const unkeyedSymbol = Symbol('un-keyed')
// for debugging
@ -201,8 +202,10 @@ function parse (tokens) {
bindings.push(binding)
// add a placeholder comment that we can find later
htmlString += (!withinTag && !withinAttribute) ? `<!--${bindings.length - 1}-->` : ''
if (!withinTag && !withinAttribute) {
// add a placeholder comment that we can find later
htmlString += `<!--${bindings.length - 1}-->`
}
}
const template = parseTemplate(htmlString)

View File

@ -38,7 +38,6 @@ export function createState (abortSignal) {
const state = new Proxy({}, {
get (target, prop) {
// console.log('reactivity: get', prop)
if (currentObserver) {
let observers = propsToObservers.get(prop)
if (!observers) {
@ -50,7 +49,6 @@ export function createState (abortSignal) {
return target[prop]
},
set (target, prop, newValue) {
// console.log('reactivity: set', prop, newValue)
target[prop] = newValue
const observers = propsToObservers.get(prop)
if (observers) {