Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/Hyperscript.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ renderdomchild(io, rctx::RenderContext, ctx, x::Nothing) = nothing

# Render and escape other HTMLSVG children, including CSS nodes, in the parent context.
# If a child is `showable` with text/html, render with that using `repr`.
renderdomchild(io, rctx::RenderContext, ctx, x) =
showable(MIME("text/html"), x) ? print(io, repr(MIME("text/html"), x)) : printescaped(io, x, escapechild(ctx))
renderdomchild(io, rctx::RenderContext, ctx, x) = print(io, repr(MIME("text/html"), x))

# All camelCase attribute names from HTML 4, HTML 5, SVG 1.1, SVG Tiny 1.2, and SVG 2
const HTML_SVG_CAMELS = Dict(lowercase(x) => x for x in [
Expand Down Expand Up @@ -470,16 +469,15 @@ struct Style
augmentcss(id, node) = Node{CSS}(
context(node),
isempty(attrs(node)) || ismedia(node) ? tag(node) : tag(node) * "[v-style$id]",
augmentcss.(id, children(node)),
Any[augmentcss(id, child) for child in children(node)],
attrs(node)
)
Style(id::Int, styles) = new(id, [augmentcss(id, node) for node in styles])
end

style_id = 0
const style_id = Ref(0)
function Style(styles...)
global style_id
Style(style_id += 1, styles)
Style(style_id[] += 1, styles)
end

styles(x::Style) = x.styles
Expand All @@ -490,12 +488,14 @@ end

augmentdom(id, x) = x # Literals and other non-HTML/SVG objects
augmentdom(id, x::Styled) = x # `Styled` nodes act as cascade barriers
augmentdom(id, node::Node{T}) where {T} = Node{T}(
context(node),
tag(node),
augmentdom.(id, children(node)),
push!(copy(attrs(node)), "v-style$id" => nothing) # note: makes a defensive copy
)
function augmentdom(id, node::Node{T}) where {T}
Node{T}(
context(node),
tag(node),
Any[augmentdom(id, child) for child in children(node)],
push!(copy(attrs(node)), "v-style$id" => nothing) # note: makes a defensive copy
)
end
(s::Style)(x::Node) = Styled(augmentdom(s.id, x), s)


Expand Down