Skip to content

Commit

Permalink
avoid skipping scripts with a specified id
Browse files Browse the repository at this point in the history
  • Loading branch information
disberd committed Oct 8, 2023
1 parent 48552a9 commit acae393
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/combine_htl/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ shouldskip(p::ScriptContent, args...) = shouldskip(p.content, args...)
shouldskip(::Any, args...) = (@nospecialize; return false)
shouldskip(n::AbstractHTML, l::SingleDisplayLocation) = (@nospecialize; shouldskip(displaylocation(n), l))

shouldskip(x::PlutoScript, ::InsidePluto) = shouldskip(x.body) && shouldskip(x.invalidation) && !hasreturn(x)
shouldskip(x::NormalScript, ::OutsidePluto) = shouldskip(x.body) && !hasreturn(x)
shouldskip(x::PlutoScript, ::InsidePluto) = shouldskip(x.body) && shouldskip(x.invalidation) && shouldskip(x.id) && !hasreturn(x)
shouldskip(x::NormalScript, ::OutsidePluto) = shouldskip(x.body) && shouldskip(x.id) && !hasreturn(x)
shouldskip(n::NonScript{L}, ::L) where L <: SingleDisplayLocation = n.empty
# Dual Script/Node
shouldskip(d::Dual, l::SingleDisplayLocation) = shouldskip(inner_node(d, l), l)
Expand Down
7 changes: 7 additions & 0 deletions test/combinehtl_module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ end
@test shouldskip(T("")) === true
end

# We should not skip a script it is empty content but with an id
@test shouldskip(PlutoScript(""), InsidePluto()) == true
@test shouldskip(PlutoScript(""; id = "lol"), InsidePluto()) == false
@test shouldskip(NormalScript(""; id = "lol"), OutsidePluto()) == false
ds = DualScript(""; id = "lol")
@test shouldskip(ds, InsidePluto()) == shouldskip(ds, OutsidePluto()) == false

for l in (InsidePluto(), OutsidePluto())
@test haslisteners(make_script("asd"), l) === false
end
Expand Down

0 comments on commit acae393

Please sign in to comment.