Comments (1)
The problem is that you are patching the <div id=app>
, replacing it with a button, then running getElementById("app")
again, at which point the element is no longer in the DOM.
<script type=module>
import { h, text, patch } from "https://unpkg.com/superfine"
const viewFixed = (state) =>
h("div", {}, [
h("button", {
onclick: () =>
render({ ...state, foo: state.foo + 1 }),
},
text("testing: " + state.foo)
),
])
const render = (state) =>
patch(document.getElementById("app"), viewFixed(state))
render({ foo: 0 })
</script>
<div id=app></div>
This works because it leaves the <div>
intact. Notice I didn't have to set id=app
because Superfine will simply recycle the given <div>
containing id=app
.
from superfine.
Related Issues (20)
- Is using custom `events` property for DOM element really future proof? HOT 3
- Is superfine a shared core of both hyperapp v1/v2 ? HOT 6
- Reference from a new virtual DOM framework project based on superfine HOT 2
- Is there any way superfine JSX/HyperScript code work on iOS/Android natively like React-Native? HOT 2
- This again: stateful components? ๐คจ HOT 16
- if-else case caused every element update HOT 1
- Lifecycle Events HOT 35
- Missing superfine.d.ts HOT 2
- Is v6 officialy depredated? HOT 2
- Usage of Props HOT 7
- V7 and Document Fragments HOT 20
- patch doesn't replace id of target node HOT 2
- node.setAttribute is not a function HOT 9
- Lifecycle events using Mutation Observer HOT 1
- Minimum example of a table with some sorting HOT 5
- Potential bug when recycling nested elements HOT 1
- Support for React-like `ref`s? HOT 23
- I create a minimalistic component based framework on the top of superfine HOT 1
- Discussion about patching shadow-root nodes? Feature request?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from superfine.