From eb6853149abaa142fab7a96904e09e825e910818 Mon Sep 17 00:00:00 2001 From: Josh Day Date: Tue, 3 Sep 2024 09:59:32 -0400 Subject: [PATCH] fix #26 --- src/XML.jl | 1 + src/raw.jl | 14 +++++++------- test/runtests.jl | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/XML.jl b/src/XML.jl index 942599f..4a3c3d9 100644 --- a/src/XML.jl +++ b/src/XML.jl @@ -206,6 +206,7 @@ Base.push!(a::Node, b::Node) = push!(a.children, b) Base.setindex!(o::Node, val, key::AbstractString) = (o.attributes[key] = string(val)) Base.getindex(o::Node, val::AbstractString) = o.attributes[val] Base.haskey(o::Node, key::AbstractString) = isnothing(o.attributes) ? false : haskey(o.attributes, key) +Base.keys(o::Node) = isnothing(o.attributes) ? () : keys(o.attributes) Base.show(io::IO, o::Node) = _show_node(io, o) diff --git a/src/raw.jl b/src/raw.jl index 9408dc8..02c89fc 100644 --- a/src/raw.jl +++ b/src/raw.jl @@ -1,16 +1,16 @@ #-----------------------------------------------------------------------------# RawType """ RawType: - - RawText # text - - RawComment # - - RawCData # - - RawDeclaration # + - RawText # text + - RawComment # + - RawCData # + - RawDeclaration # - RawProcessingInstruction # - - RawDTD # + - RawDTD # - RawElementOpen # - RawElementClose # - - RawElementSelfClosed # - - RawDocument # Something to initialize with (not really used) + - RawElementSelfClosed # + - RawDocument # Something to initialize with (not really used) """ @enum(RawType, RawDocument, RawText, RawComment, RawCData, RawProcessingInstruction, RawDeclaration, RawDTD, RawElementOpen, RawElementClose, RawElementSelfClosed) diff --git a/test/runtests.jl b/test/runtests.jl index e3b4e29..5cabd09 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -201,8 +201,10 @@ end #set/get index for attributes o = doc[end] + @test isempty(keys(o)) o["id"] = 1 @test o["id"] == "1" + @test keys(o) == keys(Dict("id" => "1")) end #-----------------------------------------------------------------------------# Issues