Sha256: d8af485178a6b56572396d0f03597ecb8e33432f1397c04ee664a379db42252b

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

# frozen_string_literal: true

require 'nokogiri'

module Nokogiri
  module XML
    class Element < Node

      #
      # Determines if the element is similar to another element.
      #
      # @param [Nokogiri::XML::Element] other
      #   The other element.
      #
      # @return [Boolean]
      #   Specifies whether the element is equal, in identity or value, to
      #   another element.
      #
      # @api public
      #
      def ==(other)
        return false unless super(other)
        return false unless attribute_nodes.length == other.attribute_nodes.length

        (0...attribute_nodes.length).each do |index|
          attr1 = attribute_nodes[index]
          attr2 = other.attribute_nodes[index]

          return false unless attr1.similar?(attr2)
        end

        return true
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokogiri-ext-0.1.1 lib/nokogiri/ext/equality/element.rb