JuliaWeb / Hyperscript.jl

Hyperscript: A lightweight DOM representation for Julia
Other
101 stars 11 forks source link

flat should accept AbstractArray #30

Closed schneiderfelipe closed 3 years ago

schneiderfelipe commented 3 years ago

I think only accepting Array in https://github.com/yurivish/Hyperscript.jl/blob/1fc13cc7cb78ec1f93c1919b80e1a1ad27a9948e/src/Hyperscript.jl#L133 is too strict.

It leads to the following surprising behavior:

julia> using Hyperscript

julia> let children = [1, 2, 3]  # Array
           m("div", children)
       end
<div>123</div>

julia> using StaticArrays

julia> let children = @SVector Int[1, 2, 3]  # not Array, but AbstractArray
           m("div", children)
       end
<div>&#91;1, 2, 3&#93;</div>
yurivish commented 3 years ago

Hi, I think that makes sense. Would you mind submitting a PR?