-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: smart diffing #40
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
import { createElement, handleProp } from "./utils/index.js"; | ||
|
||
export function render(template, host) { | ||
if (!host.__prev_watch_list__) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can combine this check in line 15 🤔
? (f(), (t = 2)) | ||
: (u += e)), | ||
3 === t && "!--" === u && ((t = 4), (o = o[0])); | ||
var n = function (t, s, r, e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if htm/mini is okay to bring back
this.onChanges({ property, previousValue, currentValue }); | ||
} | ||
} | ||
|
||
#handleUpdateProp(key, stringifiedValue) { | ||
const restored = deserialize(stringifiedValue, this.#typeMap[key]); | ||
if (restored !== this.props[key]) this.props[key] = restored; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary
@@ -111,15 +111,17 @@ export class WebComponent extends HTMLElement { | |||
this[camelCaps] = this[property]; | |||
|
|||
this.#handleUpdateProp(camelCaps, this[property]); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary
const newNode = | ||
change.type === "replace" ? change.node?.parentNode : change.node; | ||
|
||
if (newNode instanceof Node) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check is child is in parent 🤔
@@ -1,44 +1,82 @@ | |||
import { serialize } from "./serialize.mjs"; | |||
export function createElement(tree) { | |||
export function createElement(tree, watchList = []) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add JSDoc
@@ -1,44 +1,82 @@ | |||
import { serialize } from "./serialize.mjs"; | |||
export function createElement(tree) { | |||
export function createElement(tree, watchList = []) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require watchList and remove default
|
||
function h(type, props, ...children) { | ||
return { type, props, children }; | ||
const r = { type, props, children }; | ||
return r; | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark dynamic DOM (lookout for tree === false
)
} else if (prop in el) { | ||
el[prop] = value; | ||
} else if (domProp in el) { | ||
el[domProp] = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See if setAttribute
is enough. Look out for
- class & className
- for
- onclick & onClick
"include": [ | ||
"src/*", | ||
"src/utils/*", | ||
"src/render.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary
fixes #24
This implements diffing by
Left todo