Class: CustomElementsManifestParser::Structs::CustomElementLikeStruct
- Inherits:
-
BaseStruct
- Object
- Dry::Struct
- BaseStruct
- CustomElementsManifestParser::Structs::CustomElementLikeStruct
- Includes:
- Structs::ClassLikeStruct
- Defined in:
- lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb
Overview
The additional fields that a custom element adds to classes and mixins.
Instance Attribute Summary collapse
-
#attributes ⇒ Array<Attribute>?
- The attributes that this element is known to understand.
-
#cssParts ⇒ Array<CssPart>?
- Array of CSS Parts.
- #cssProperties ⇒ Array<CssCustomProperty>?
-
#customElement ⇒ True
- Distinguishes a regular JavaScript class from a custom element class.
-
#events ⇒ Array<Event>?
- The events that this element fires.
-
#slots ⇒ Array<Slot>?
- The shadow dom content slots that this element accepts.
-
#tagName ⇒ String?
- An optional tag name that should be specified if this is a self-registering element.
Class Method Summary collapse
Instance Attribute Details
#attributes ⇒ Array<Attribute>?
Returns - The attributes that this element is known to understand.
26 |
# File 'lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb', line 26 attribute :attributes, Types::Strict::Array.optional.(required: false) |
#cssParts ⇒ Array<CssPart>?
Returns - Array of CSS Parts.
37 |
# File 'lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb', line 37 attribute :cssParts, Types::Strict::Array.optional.(required: false) |
#cssProperties ⇒ Array<CssCustomProperty>?
33 |
# File 'lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb', line 33 attribute :cssProperties, Types::Strict::Array.optional.(required: false) |
#customElement ⇒ True
Returns - Distinguishes a regular JavaScript class from a custom element class.
13 |
# File 'lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb', line 13 attribute :customElement, Types::Strict::True.optional.(required: false) |
#events ⇒ Array<Event>?
Returns - The events that this element fires.
45 |
# File 'lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb', line 45 attribute :events, Types::Strict::Array.optional.(required: false) |
#slots ⇒ Array<Slot>?
Returns - The shadow dom content slots that this element accepts.
41 |
# File 'lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb', line 41 attribute :slots, Types::Strict::Array.optional.(required: false) |
#tagName ⇒ String?
Returns - An optional tag name that should be specified if this is a self-registering element.
Self-registering elements must also include a CustomElementExport in the module's exports.
22 |
# File 'lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb', line 22 attribute :tagName, Types::Strict::String.optional.(required: false) |
Class Method Details
.build_hash(parser:, struct:) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb', line 47 def self.build_hash(parser:, struct:) hash = {} # This is a special case because DryStruct reserves the `attributes` namespace. hash[:attributes] = struct.attributes[:attributes].map { |attr| parser.data_types[:attribute].new(attr).visit(parser: parser) } unless struct.attributes[:attributes].nil? hash[:cssProperties] = struct.cssProperties.map { |css_custom_property| parser.data_types[:css_custom_property].new(css_custom_property).visit(parser: parser) } unless struct.cssProperties.nil? hash[:cssParts] = struct.cssParts.map { |css_part| parser.data_types[:css_part].new(css_part).visit(parser: parser) } unless struct.cssParts.nil? hash[:demos] = struct.demos.map { |demo| parser.data_types[:demo].new(demo).visit(parser: parser) } unless struct.demos.nil? hash[:slots] = struct.slots.map { |slot| parser.data_types[:slot].new(slot).visit(parser: parser) } unless struct.slots.nil? hash[:events] = struct.events.map { |event| parser.data_types[:event].new(event).visit(parser: parser) } unless struct.events.nil? hash = hash.merge(ClassLikeStruct.build_hash(parser: parser, struct: struct)) hash end |