Sha256: fd89fb35ddc00c17e7c7f15d2a7c3f0315bf1f1417a852733cf9cff01111fdac

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  class DeprecateLazysizes < HtmlCheck
    severity :suggestion
    category :html, :performance
    doc docs_url(__FILE__)

    def on_img(node)
      class_list = node.attributes["class"]&.split(" ")
      add_offense("Use the native loading=\"lazy\" attribute instead of lazysizes", node: node) if class_list&.include?("lazyload")
      add_offense("Use the native srcset attribute instead of data-srcset", node: node) if node.attributes["data-srcset"]
      add_offense("Use the native sizes attribute instead of data-sizes", node: node) if node.attributes["data-sizes"]
      add_offense("Do not set the data-sizes attribute to auto", node: node) if node.attributes["data-sizes"] == "auto"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
theme-check-1.3.0 lib/theme_check/checks/deprecate_lazysizes.rb