# File lib/html/selector.rb, line 769
769:     def only_child(of_type)
770:       lambda do |element|
771:         # Element must be inside parent element.
772:         return false unless element.parent and element.parent.tag?
773:         name = of_type ? element.name : nil
774:         other = false
775:         for child in element.parent.children
776:           # Skip text nodes/comments.
777:           if child.tag? and (name == nil or child.name == name)
778:             unless child.equal?(element)
779:               other = true
780:               break
781:             end
782:           end
783:         end
784:         !other
785:       end
786:     end