diff --git a/.travis.yml b/.travis.yml index 97869d5..a75851e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ os: - linux - osx julia: - - 0.5 - 0.6 - nightly matrix: diff --git a/REQUIRE b/REQUIRE index 3c336dc..54bc3f1 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,4 @@ julia 0.5 Compat 0.23.0 BinDeps -AbstractTrees 0.0.4 \ No newline at end of file +AbstractTrees 0.1.0 \ No newline at end of file diff --git a/src/htmltypes.jl b/src/htmltypes.jl index d8cd586..3f3444b 100644 --- a/src/htmltypes.jl +++ b/src/htmltypes.jl @@ -2,10 +2,8 @@ using Compat @compat abstract type HTMLNode end -# TODO change all these to use struct / mutable struct in the next release - # TODO immutable? -type HTMLText <: HTMLNode +struct HTMLText <: HTMLNode parent::HTMLNode text::AbstractString end @@ -13,9 +11,9 @@ end # convenience method for defining without parent HTMLText(text::AbstractString) = HTMLText(NullNode(), text) -type NullNode <: HTMLNode end +struct NullNode <: HTMLNode end -type HTMLElement{T} <: HTMLNode +mutable struct HTMLElement{T} <: HTMLNode children::Vector{HTMLNode} parent::HTMLNode attributes::Dict{AbstractString,AbstractString} @@ -24,11 +22,11 @@ end # convenience method for defining an empty element HTMLElement(T::Symbol) = HTMLElement{T}(HTMLNode[],NullNode(),Dict{AbstractString,AbstractString}()) -type HTMLDocument +mutable struct HTMLDocument doctype::AbstractString root::HTMLElement end -type InvalidHTMLException <: Exception +struct InvalidHTMLException <: Exception msg::AbstractString end diff --git a/src/manipulation.jl b/src/manipulation.jl index 9f8c92e..7f4d27b 100644 --- a/src/manipulation.jl +++ b/src/manipulation.jl @@ -1,8 +1,6 @@ # functions for accessing and manipulation HTML types import AbstractTrees -import Base: depwarn - # elements tag{T}(elem::HTMLElement{T}) = T @@ -13,12 +11,13 @@ function setattr!(elem::HTMLElement, name::AbstractString, value::AbstractString end getattr(elem::HTMLElement, name) = elem.attributes[name] - AbstractTrees.children(elem::HTMLElement) = elem.children -# TODO sometimes convenient but this should arguably be an error -# breadthfirst traversal will have to be updated -AbstractTrees.children(elem::HTMLNode) = HTMLNode[] +# TODO there is a naming conflict here if you want to use both packages +# (see https://github.com/porterjamesj/Gumbo.jl/issues/31) +# +# I still think exporting `children` from Gumbo is the right thing to +# do, since it's probably more common to be using this package alone children = AbstractTrees.children @@ -32,16 +31,3 @@ Base.push!(elem::HTMLElement,val) = push!(elem.children, val) # text text(t::HTMLText) = t.text - -# tree traversals, deprecated wrappers around AbstractTrees - -for (name, replacement) in [(:preorder, :PreOrderDFS), - (:postorder, :PostOrderDFS), - (:breadthfirst, :StatelessBFS)] - @eval @deprecate $name(e::HTMLElement) AbstractTrees.$replacement(e) - @eval function $name(f::Function, el::HTMLElement) - for node in $name(el) - f(node) - end - end -end diff --git a/test/comparison.jl b/test/comparison.jl index a4d40b6..d3105cf 100644 --- a/test/comparison.jl +++ b/test/comparison.jl @@ -4,14 +4,11 @@ let x = HTMLText("test") y = HTMLText("test") + x1 = HTMLText("test1") @test x == y @test hash(x) == hash(y) - x.text *= "1" - @test x != y - @test hash(x) != hash(y) - y.text *= "1" - @test x == y - @test hash(x) == hash(y) + @test x1 != y + @test hash(x1) != hash(y) end let