client/hyalite/dom_property_operations.rb in hyalite-0.0.6 vs client/hyalite/dom_property_operations.rb in hyalite-0.1.0
- old
+ new
@@ -11,30 +11,30 @@
if property_info
return if should_ignore_value(property_info, value)
attribute_name = property_info[:attribute_name]
if property_info[:has_boolean_value] || property_info[:has_overloaded_boolean_value] && value == true
- element[attribute_name] = ""
+ element.attributes[attribute_name] = ""
return
end
- element[attribute_name]=Hyalite.escape_text_content_for_browser(value)
+ element.attributes[attribute_name]=Hyalite.escape_text_content_for_browser(value)
elsif DOMProperty.is_custom_attribute(name)
return if value.nil?
- element[name]=Hyalite.escape_text_content_for_browser(value)
+ element.attributes[name]=Hyalite.escape_text_content_for_browser(value)
end
end
def create_markup_for_styles(element, styles)
element.style(styles)
end
def create_markup_for_custom_attribute(element, name, value)
return if (!is_attribute_name_safe(name) || value == null)
- element[name]=Hyalite.escape_text_content_for_browser(value)
+ element.attributes[name]=Hyalite.escape_text_content_for_browser(value)
end
def is_attribute_name_safe(attribute_name)
@illegal_attribute_name_cache ||= {}
@validated_attribute_name_cache ||= {}
@@ -61,16 +61,16 @@
delete_value_for_property(node, name)
elsif property_info[:must_use_attribute]
attribute_name = property_info[:attribute_name]
namespace = property_info[:attribute_namespace]
if namespace
- node[attribute_name, {namespace: namespace}] = value.to_s
+ node.attributes[attribute_name, {namespace: namespace}] = value.to_s
elsif property_info[:has_boolean_value] ||
(property_info[:has_overloaded_boolean_value] && value == true)
- node[attribute_name] = ''
+ node.attributes[attribute_name] = ''
else
- node[attribute_name] = value.to_s
+ node.attributes[attribute_name] = value.to_s
end
else
prop_name = property_info[:property_name]
unless property_info[:has_side_effects] && `'' + node[#{prop_name}]` == value.to_s
`node.native[#{prop_name}] = value`
@@ -100,10 +100,10 @@
node.remove_attribute(name)
end
end
def set_attribute_for_id(node, id)
- node[DOMProperty::ID_ATTRIBUTE_NAME] = id
+ node.attributes[DOMProperty::ID_ATTRIBUTE_NAME] = id
end
def should_ignore_value(property_info, value)
value.nil? ||
(property_info[:has_boolean_value] && !value) ||