Skip to content
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

Reactive Dict with string keys: curly braces not escaped properly #135

Closed
jochenkrattenmacher opened this issue Aug 3, 2022 · 3 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@jochenkrattenmacher
Copy link
Contributor

jochenkrattenmacher commented Aug 3, 2022

Heyo!

Not sure whether this is going to be practically relevant (for me it isn't really), but here goes:

If I have a model as follows:

@reactive! mutable struct Test <: ReactiveModel
    test::R{Dict{String, Int8}} = Dict("a{b}" => 1)
end

then the browser console throws me an error:

Uncaught SyntaxError: missing : after property id vartest323.js:5:115]

The problem seems to be that the curly braces are not escaped properly somehow (there is no issue with keys not containing special characters):

function initStipple(rootSelector){
Stipple.init({theme: 'stipple-blue'});
window.varTest323 = new Vue({"el":rootSelector,"mixins":[watcherMixin, reviveMixin],"data":{"test":{"a{b} :1},"isready":false,"isprocessing":false}});
} // end of initStipple

(there is a quote missing after a{b})

Here is the full MWE:

using Stipple

@reactive! mutable struct Test <: ReactiveModel
    test::Dict{String, Int8} = Dict("a{b}" => 1)
end

function handlers(model)
    on(model.isready) do isready
        isready || return
        push!(model)
    end
    return model
end

function ui(model)
    page(
        model,
        title = "Hello Stipple",
        cell("test"),
    )
end


route("/") do
    # global model definition is for debugging/testing purpose only
    global model 
    model = Stipple.init(Test)
    model |> handlers |> ui |> html
end

up(8080)
@jochenkrattenmacher jochenkrattenmacher changed the title Reactive Dict with string keys Reactive Dict with string keys: curly braces not escaped properly Aug 3, 2022
@essenciary essenciary self-assigned this Sep 14, 2023
@essenciary essenciary added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Sep 14, 2023
@hhaensel
Copy link
Member

hhaensel commented Oct 1, 2023

This is related to lines 56-57 of Elements.jl.
Not sure, if the replacement is needed at all anymore.

  vue_app = replace(json(model |> Stipple.render), "\"{" => " {")
  vue_app = replace(vue_app, "}\"" => "} ")

@hhaensel
Copy link
Member

hhaensel commented Apr 1, 2024

@jochenkrattenmacher
I think, it's not! We eliminated these lines for the Vue3 branches which are to be released soon, and have seen no negative effect.

@protozoo, @essenciary , @PGimenez
Should we backport this to the Vue2 branch?

@hhaensel
Copy link
Member

hhaensel commented May 3, 2024

I did backport to Vue2 by releasing version 0.29 today. So this should be fixed.

@hhaensel hhaensel closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants