New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML5 custom hyphenated attribute #807

Closed
cuihq opened this Issue Apr 13, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@cuihq

cuihq commented Apr 13, 2018

Issues:

slim code:

div data={object_id: 1}

html expect:

<div data-object_id="1"></div>

html actual:

<div data-object-id="1"></div>

Reason:

The custom attributes are all underscore.
Do not need to switch between underscore and dasherize (camelize).
So compatibility is better.

  • compatible with ruby
{object_id: 1} # not {'object-id' => 1} or {objectId: 1}
  • compatible with javascript/coffeescript
element.dataset.object_id // not element.dataset.objectId
  • compatible whit jQuery
$(element).data('object_id') // not $(element).data('objectId')

Validate:

validate attribute data-object_id:

Code:

hyphen_attr("#{name}-#{n.to_s.gsub('_', '-')}", escape, v)

modified code:

hyphen_attr("#{name}-#{n}", escape, v)

Test:

Test code that needs to be changed:

def test_hyphenated_attribute

stonean added a commit that referenced this issue Jul 14, 2018

@stonean stonean closed this Jul 14, 2018

stonean added a commit that referenced this issue Jul 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment