Skip to content

Commit

Permalink
doc: note that Node#kwattr methods appeared in v1.11.0
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
flavorjones committed Feb 26, 2020
1 parent 748aff9 commit d852d97
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/nokogiri/xml/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ def remove_class(names = nil)
# node # => <a rel="nofollow noopener external">link</a>
# node.kwattr_values("rel") # => ["nofollow", "noopener", "external"]
#
# @since v1.11.0
#
def kwattr_values(attribute_name)
keywordify(get_attribute(attribute_name) || [])
end
Expand Down Expand Up @@ -651,6 +653,8 @@ def kwattr_values(attribute_name)
# node # => <a></a>
# node.kwattr_add("rel", ["nofollow", "noreferrer"]) # => <a rel="nofollow noreferrer"></a>
#
# @since v1.11.0
#
def kwattr_add(attribute_name, keywords)
keywords = keywordify(keywords)
current_kws = kwattr_values(attribute_name)
Expand Down Expand Up @@ -701,6 +705,8 @@ def kwattr_add(attribute_name, keywords)
# node # => <a></a>
# node.kwattr_append("rel", ["nofollow", "noreferrer"]) # => <a rel="nofollow noreferrer"></a>
#
# @since v1.11.0
#
def kwattr_append(attribute_name, keywords)
keywords = keywordify(keywords)
current_kws = kwattr_values(attribute_name)
Expand Down Expand Up @@ -745,6 +751,8 @@ def kwattr_append(attribute_name, keywords)
# node.kwattr_remove("rel", "nofollow") # => <a rel="noreferrer">link</a>
# node.kwattr_remove("rel", "noreferrer") # => <a>link</a> # attribute is deleted when empty
#
# @since v1.11.0
#
def kwattr_remove(attribute_name, keywords)
if keywords.nil?
remove_attribute(attribute_name)
Expand Down

0 comments on commit d852d97

Please sign in to comment.