Comments (8)
this doesn't seem right ... I'll have a look, thanks for filing the bug 👍
from uhtml.
from uhtml.
So, I've tried in codepen, it works.
import {render, html} from '//unpkg.com/uhtml?module';
const items = [{text: "test item"}];
render(document.body, html`
<ul>
${items.map(item => html.for(item)`
<li>Keyed row with content: ${item.text}</li>
`)}
</ul>
`);
Then I've tested your code, and noticed that you try to access the DOM before it's even created.
Move the script down the page or use DOMContentLoaded or load listeners.
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/uhtml"></script>
<head>
<body>
<script>
addEventListener('DOMContentLoaded', () => {
const html = uhtml.html,
render = uhtml.render,
items = [{text:"test item"}];
render(document.getElementById("app"), html`
<ul>
${items.map(item => html.for(item)`
<li>Keyed row with content: ${item.text}</li>
`)}
</ul>
`);
});
</script>
<div id="app">
</div>
</body>
</html>
from uhtml.
P.S. the error is that document.getElementById("app")
was returning null, as you had the script evaluated before <div id="app">
... nothing to do with this library, this is the ABC of any script ;-)
from uhtml.
@WebReflection Wow, that was stupid of me. Hundreds of web pages developed with similar tech and I make such a naive mistake after looking at the code for hours! Sorry for wasting your time.
from uhtml.
it happens to the best too :-) it took far too much for me to notice that too
from uhtml.
This also happened to me today. If it's a common enough bug maybe it's worth it to have a clearer error message like "where is null".
from uhtml.
the stack error should immediately point at the render
function called with a null
/ undefined
value ... not sure adding extra bytes to point at the very same thing makes sense ... be sure you render in nodes that exists, this library can't fix this mistake.
from uhtml.
Related Issues (20)
- Error with Parcel HOT 3
- Recursive fragment w/ lost lastChild during target update HOT 16
- This sequence of renders crashes in both V3 and V4 HOT 15
- Custom Element setters no longer called when uhtml renders them with a direct attribute HOT 9
- Bug? Rendering as dom element broken for 4.4.1, not 4.3.5 HOT 14
- Disconnected custom elements do not unsubscribe from effects HOT 9
- 4.8 breaks semver HOT 4
- Exception thrown when rendering a <template> element with placeholder content HOT 7
- Type definitions are buggy HOT 3
- What about types? HOT 27
- Can' figure how to use reactivity & lists HOT 2
- Render unsafe content with V4 HOT 7
- Small issue with v4 HOT 9
- Cannot render empty array HOT 2
- Clarify CJS usage in v4 / CJS report with v4 HOT 1
- Typescript issues HOT 13
- Consider bringing global `uhtml` export back HOT 1
- Cannot set property list of #<HTMLInputElement> which has only a getter HOT 10
- Functions no longer allowed as Holes? HOT 3
- V4 crashes on empty array HOT 10
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 uhtml.