Class: Dommy::HTMLTextAreaElement
Overview
‘<textarea>` — multi-line text input.
Constant Summary
Constants inherited
from Element
Element::ATTRIBUTE_NODE, Element::CDATA_SECTION_NODE, Element::COMMENT_NODE, Element::DOCUMENT_FRAGMENT_NODE, Element::DOCUMENT_NODE, Element::DOCUMENT_POSITION_CONTAINED_BY, Element::DOCUMENT_POSITION_CONTAINS, Element::DOCUMENT_POSITION_DISCONNECTED, Element::DOCUMENT_POSITION_FOLLOWING, Element::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, Element::DOCUMENT_POSITION_PRECEDING, Element::DOCUMENT_TYPE_NODE, Element::ELEMENT_NODE, Element::HTML_NAMESPACE, Element::PROCESSING_INSTRUCTION_NODE, Element::REFLECTED_TOKEN_LIST_HOSTS, Element::SHADOW_HOST_TAGS, Element::SVG_NAMESPACE, Element::TEXT_NODE
Constants included
from Node
Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAGMENT_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_POSITION_CONTAINED_BY, Node::DOCUMENT_POSITION_CONTAINS, Node::DOCUMENT_POSITION_DISCONNECTED, Node::DOCUMENT_POSITION_FOLLOWING, Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, Node::DOCUMENT_POSITION_PRECEDING, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::HTML_NAMESPACE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE
Instance Attribute Summary
Attributes inherited from Element
#document
Instance Method Summary
collapse
Methods inherited from HTMLElement
#case_sensitive_attribute_names?
included
Methods inherited from Element
#[], #[]=, #__dommy_backend_node__, #__internal_set_namespace__, #__internal_shadow_root__, #__test_scroll_log__, #access_key_label, #after, #anchor_href, #animate, #aria_content_attr, #aria_element_attr, #aria_element_get, #aria_element_set, #aria_elements_attr, #aria_elements_get, #aria_elements_set, #aria_find_in_root, #aria_get, #aria_set, #at_xpath, #attach_shadow, #attributes, #base_uri, #before, #blur, #child_element_count, #child_nodes, #children, #class_list, #class_name, #class_name=, #clear_aria_element_ref_for, #click, #clone_node, #closest, #contains?, #dataset, #element_prefix, #equal_node?, #first_child, #first_element_child, #focus, #get_animations, #get_attribute, #get_attribute_names, #get_attribute_node, #get_attribute_node_ns, #get_attribute_ns, #get_bounding_client_rect, #get_client_rects, #get_elements_by_class_name, #get_elements_by_tag_name, #get_elements_by_tag_name_ns, #get_html, #get_inner_html, #has_attribute?, #has_attribute_ns?, #has_attributes?, #has_child_nodes?, #hide_popover, #id, #id=, #initialize, #inner_html, #inner_html=, #insert_adjacent_element, #insert_adjacent_html, #insert_adjacent_text, #insert_before, #insertion_parent!, #is_connected?, #last_child, #last_element_child, #live_child_nodes, #local_name, #matches?, #namespace_uri, #next_element_sibling, #next_sibling, #normalize, #on, #outer_html, #outer_html=, #owner_document, #parent_element, #parent_node, #path, #previous_element_sibling, #previous_sibling, #query_selector, #query_selector_all, #reflected_attr_name, #reflected_token_list, #remove, #remove_attribute, #remove_attribute_node, #remove_attribute_ns, #remove_child, #replace_child, #replace_with_nodes, #request_fullscreen, #role, #role=, #root_node, #same_node?, #scoped_query, #set_attribute, #set_attribute_node, #set_attribute_ns, #shadow_root, #show_popover, #slot, #slot=, #style, #tag_name, #text_content, #text_content=, #to_s, #toggle_attribute, #toggle_popover, #with_selector_errors, #xpath
included
#append, #append_child, #prepend, #replace_children
Methods included from Node
#compare_document_position, #get_root_node, #is_default_namespace, #is_equal_node, #is_same_node, #lookup_namespace_uri, #lookup_prefix
#__internal_deliver_event__, #__internal_event_parent__, #add_event_listener, capture_flag, #deliver_at, #dispatch_event, js_truthy?, #remove_event_listener
Constructor Details
This class inherits a constructor from Dommy::Element
Instance Method Details
#__js_call__(method, args) ⇒ Object
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
|
# File 'lib/dommy/html_elements.rb', line 1173
def __js_call__(method, args)
case method
when "select"
select
when "setSelectionRange"
set_selection_range(args[0], args[1], args[2])
when "setRangeText"
set_range_text(args[0])
when "checkValidity"
check_validity
when "reportValidity"
report_validity
when "setCustomValidity"
set_custom_validity(args[0])
else
super
end
end
|
#__js_get__(key) ⇒ Object
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
|
# File 'lib/dommy/html_elements.rb', line 1118
def __js_get__(key)
case key
when "value"
value
when "defaultValue"
default_value
when "rows"
rows
when "cols"
cols
when "maxLength"
max_length
when "minLength"
min_length
when "textLength"
text_length
when "type"
type
when "form"
form
when "labels"
labels
when "validity"
validity
when "willValidate"
will_validate
when "validationMessage"
validation_message
else
super
end
end
|
#__js_set__(key, v) ⇒ Object
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
|
# File 'lib/dommy/html_elements.rb', line 1151
def __js_set__(key, v)
case key
when "value"
self.value = v
when "defaultValue"
self.default_value = v
when "rows"
self.rows = v
when "cols"
self.cols = v
when "maxLength"
set_reflected_string("maxlength", v.to_s)
when "minLength"
set_reflected_string("minlength", v.to_s)
else
super
end
end
|
#check_validity ⇒ Object
1103
1104
1105
1106
1107
|
# File 'lib/dommy/html_elements.rb', line 1103
def check_validity
ok = !will_validate || validity.valid
dispatch_event(Event.new("invalid", "bubbles" => false, "cancelable" => true)) unless ok
ok
end
|
#cols ⇒ Object
1038
1039
1040
|
# File 'lib/dommy/html_elements.rb', line 1038
def cols
(@__node__["cols"] || "20").to_i
end
|
#cols=(v) ⇒ Object
1042
1043
1044
|
# File 'lib/dommy/html_elements.rb', line 1042
def cols=(v)
set_reflected_string("cols", v.to_s)
end
|
#default_value ⇒ Object
1022
1023
1024
|
# File 'lib/dommy/html_elements.rb', line 1022
def default_value
text_content
end
|
#default_value=(v) ⇒ Object
1026
1027
1028
|
# File 'lib/dommy/html_elements.rb', line 1026
def default_value=(v)
self.text_content = v
end
|
1062
1063
1064
|
# File 'lib/dommy/html_elements.rb', line 1062
def form
closest("form")
end
|
#labels ⇒ Object
1066
1067
1068
1069
1070
|
# File 'lib/dommy/html_elements.rb', line 1066
def labels
return [] if id.empty?
@document.query_selector_all("label[for='#{id}']")
end
|
#max_length ⇒ Object
1046
1047
1048
|
# File 'lib/dommy/html_elements.rb', line 1046
def max_length
(@__node__["maxlength"] || "-1").to_i
end
|
#min_length ⇒ Object
1050
1051
1052
|
# File 'lib/dommy/html_elements.rb', line 1050
def min_length
(@__node__["minlength"] || "-1").to_i
end
|
#report_validity ⇒ Object
1109
1110
1111
|
# File 'lib/dommy/html_elements.rb', line 1109
def report_validity
check_validity
end
|
#rows ⇒ Object
1030
1031
1032
|
# File 'lib/dommy/html_elements.rb', line 1030
def rows
(@__node__["rows"] || "2").to_i
end
|
#rows=(v) ⇒ Object
1034
1035
1036
|
# File 'lib/dommy/html_elements.rb', line 1034
def rows=(v)
set_reflected_string("rows", v.to_s)
end
|
#select ⇒ Object
No real selection — same stub story as input.
1073
1074
1075
|
# File 'lib/dommy/html_elements.rb', line 1073
def select
nil
end
|
#set_custom_validity(msg) ⇒ Object
1113
1114
1115
1116
|
# File 'lib/dommy/html_elements.rb', line 1113
def set_custom_validity(msg)
@custom_validity_message = msg.to_s
nil
end
|
#set_range_text(_replacement, *_) ⇒ Object
1081
1082
1083
|
# File 'lib/dommy/html_elements.rb', line 1081
def set_range_text(_replacement, *_)
nil
end
|
#set_selection_range(_s, _e, _direction = nil) ⇒ Object
1077
1078
1079
|
# File 'lib/dommy/html_elements.rb', line 1077
def set_selection_range(_s, _e, _direction = nil)
nil
end
|
#text_length ⇒ Object
1054
1055
1056
|
# File 'lib/dommy/html_elements.rb', line 1054
def text_length
value.length
end
|
#type ⇒ Object
1058
1059
1060
|
# File 'lib/dommy/html_elements.rb', line 1058
def type
"textarea"
end
|
#validation_message ⇒ Object
1093
1094
1095
1096
1097
1098
1099
1100
1101
|
# File 'lib/dommy/html_elements.rb', line 1093
def validation_message
return "" unless will_validate
msg = (@custom_validity_message || "").to_s
return msg unless msg.empty?
return "Please fill out this field." if validity.value_missing
""
end
|
#validity ⇒ Object
1085
1086
1087
|
# File 'lib/dommy/html_elements.rb', line 1085
def validity
@__validity ||= ValidityState.new(self)
end
|
#value ⇒ Object
Own js_call methods, on top of Element’s.
1013
1014
1015
|
# File 'lib/dommy/html_elements.rb', line 1013
def value
@__node__["value"] || text_content
end
|
#value=(v) ⇒ Object
1017
1018
1019
1020
|
# File 'lib/dommy/html_elements.rb', line 1017
def value=(v)
@__node__["value"] = v.to_s
self.text_content = v.to_s
end
|
#will_validate ⇒ Object
1089
1090
1091
|
# File 'lib/dommy/html_elements.rb', line 1089
def will_validate
!reflected_boolean("disabled") && !reflected_boolean("readonly")
end
|