Code Monkey home page Code Monkey logo

Comments (31)

rbiggs avatar rbiggs commented on April 27, 2024 1

I was just looking at the error from the svg clock in Codepen. The error is being thrown by the patch function" var i = e.childNodes[r];. Something about how you're patching the DOM. I am getting the same error with nichoth's example of counters with child elements when I set it to render with a root element. No problem if it just gets appended to the body. nichoth's example. So you might want to look carefully at that patch function for some edge case that is throwing errors.

from hyperapp.

selfup avatar selfup commented on April 27, 2024 1

@tunnckoCore I ran into that length of undefined error but it was just because I didn't close some html tag properly 😂

I was using components approach as well: https://github.com/selfup/hyperapp-idea-box/blob/master/src/views/IdeaBox.js

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024 1

Ah, components, haven't forgotten about #2. We'll get there too, somewhat, somehow.

from hyperapp.

selfup avatar selfup commented on April 27, 2024 1

@tunnckoCore I guess it's one component but with multiple views (stateless functional components in React). Using model as the entire application state tree. Just wanted to try it out haha

from hyperapp.

selfup avatar selfup commented on April 27, 2024 1

@jbucaran I am on 0.0.9, I can update to see if I get the same behavior

Update

Everything seems fine with 0.0.11: http://selfup.me/hyperapp-idea-box/

Still amazed at how fast that reloads (refresh render is super fast even from localStorage) mind blown

🎉

Another Update

With 10 "todos" from localStorage after refresh (in incognito with no extensions):

wow-fast

I am using my own localStorage npm module lspi, so if it's somehow slower than you thought it can be because of that 😂

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024 1

@juxtar IIRC update is still supported in 0.4.2, but I plan to remove it soon.

Thanks, I've updated the examples to use reducers now. Also thanks for figuring out that attributes is what breaks svg in CodePen, that's a hint.

So, to summarize, SVG works when running from your own server (gomix, localhost), but fails in CodePen, specifically, when using attributes.

Could this be like a CodePen/JsFiddle security feature or something?

from hyperapp.

rbiggs avatar rbiggs commented on April 27, 2024 1

hmmm... Maybe it's a Browserify issue with the SVG. I've used SVG with JavaScript in the browser without namespaces before.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024 1

@rbiggs @juxtar @selfup Clock example now working.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

I was able to run the program correctly locally using a simple server. The only instance in which svg fails is on CodePen or when opening an index.html file directly in the browser locally (no server).

This is weird.

from hyperapp.

rbiggs avatar rbiggs commented on April 27, 2024

For me, no problem rendering the SVG clock example running on localhost, Chrome and Safari both. But I can't get the setLocation example to work running locally. Maybe something to do with localhost? I see it works fine on the Gomix server.

from hyperapp.

tunnckoCore avatar tunnckoCore commented on April 27, 2024

@rbiggs not the only bug coming from patch btw.

@jbucaran when I was playing with the "todo example with components approach" i faced some similar issue or maybe it was kinda "length of undefined" from for (var i = 0; i < node.tree.length; i++) { - that's easy fix, but i'm not sure.

kinda related #39

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

@tunnckoCore 🤔 Any code you could share?

from hyperapp.

tunnckoCore avatar tunnckoCore commented on April 27, 2024

@selfup don't know ;d idea box looks cool, gj

@jbucaran i don't think so...

edit: @selfup, that's single component and single app 😂

from hyperapp.

tunnckoCore avatar tunnckoCore commented on April 27, 2024

@jbucaran yep, i'm working on it ;d

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

But I can't get the setLocation example to work running locally. Maybe something to do with localhost? I see it works fine on the Gomix server.

Router examples using a local server should work. Make sure you are not using a buggy release, there were a few of those recently (like literally the router was broken for a while), during the ES6ish rewrite.

from hyperapp.

juxtar avatar juxtar commented on April 27, 2024

@jbucaran Hey, SVG rendering is failing for me once again on 0.4.2
It was working up until 0.2.1 I believe (before the updates to reducers renaming) and that's what the live example seems to be using.

It breaks when you assign attributes to the svg. Here's a CodePen for a working but useless svg and the broken one.

from hyperapp.

juxtar avatar juxtar commented on April 27, 2024

@jbucaran It's actually failing in my localhost too. Am I doing something wrong? The code (and the error) is the same as in the CodePens.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

@juxtar Something obvious is happening on the server that works that we're just missing.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

@juxtar You're right, 0.2.1 works, but 0.4.2 doesn't! This bug is fun.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

Okay, this is really weird, but it seems SVG elements (namespace) .ns is undefined only in the minified bundle.

Back in 0.2.1 we were still using commonjs, so the example that works is using the source directly.

Maybe this is an uglifyjs issue or how we're using it.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

Could this be a race condition? Very cool bug, should get the hyperapp bug awards this month.

from hyperapp.

rbiggs avatar rbiggs commented on April 27, 2024

Maybe something about how Browserify injects things into the browser, combined with iframes on GoMix causing, well, iframe pain.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

I'll dig more. Now that I know the cause, the fix is rather simple, but now I have to know why .ns is undefined only when using the uglified bundle.

from hyperapp.

rbiggs avatar rbiggs commented on April 27, 2024

Well, I noticed on the failing GoMix svg that's JSX that you have viewbox but no namespace. Try putting it in.

from hyperapp.

rbiggs avatar rbiggs commented on April 27, 2024

i'm sure the JSX Babel plugin doesn't add it automatically.

from hyperapp.

rbiggs avatar rbiggs commented on April 27, 2024

So i'm getting an error: 155:118TypeError: Attempted to assign to readonly property.

from hyperapp.

rbiggs avatar rbiggs commented on April 27, 2024

So after looking at the clock and playing with it locally I think I see why it sometimes doesn't work. x2 and y2 are attributes on the svg line. Therefore we're sometimes getting the error: Attempted to assign to a readonly property. That's because the example is trying to set the value of an attribute dynamically directly on that. Bad boy. Gotta use setAttribute in those cases.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

Bug is/was "use strict"! :feelsgood:

Removing "use strict" from the bundle fixed the problem. Or to be more specific, "use strict" causes setting a property in an element like this:

element[name] = value

to fail for read only properties, hence SVG complaining.

Setting the attribute like this:

element.setAttribute(name, value)

works alright.

Possible solutions:

  1. not use "use strict" (perhaps a bad idea) or
  2. avoid setting a property in a SVG element.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

Fixed in 0.5.0! 💥

from hyperapp.

rbiggs avatar rbiggs commented on April 27, 2024

Yup, I notice after I updated my GoMix to 0.5.0

from hyperapp.

selfup avatar selfup commented on April 27, 2024

Ok I take 5.0 seems to be a healthy version :) I will update all my things to 5.0 now and report back!

from hyperapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.