Skip to content

Replace jQuery example with plain JavaScript #9528

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

Merged
merged 1 commit into from
Apr 3, 2018
Merged

Replace jQuery example with plain JavaScript #9528

merged 1 commit into from
Apr 3, 2018

Conversation

msheakoski
Copy link
Contributor

The data attributes example relies unnecessarily on jQuery and is potentially more confusing because it masks how attributes actually work in JavaScript and it's another level of abstraction to deal with. It is a better idea to promote web standards here because people tend to copy what they see, so let's steer them in a future-friendly direction.

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this a lot! Thanks for this improvement. I'd like to make a minot suggestion though. What if we turn this into a note and reword the link to MDN docs to make it more concise? Like this:

.. note::

    When `accessing data attributes from JavaScript`_, the attribute names are
    converted from dash-style to camelCase. For example, ``data-is-authenticated``
    becomes ``isAuthenticated`` and ``data-number-of-reviews`` becomes
    ``numberOfReviews``.


.. _`accessing data attributes from JavaScript`: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes

@msheakoski
Copy link
Contributor Author

@javiereguiluz I agree, your suggestion makes it look better and reads more clearly. I have updated this PR.

@javiereguiluz javiereguiluz changed the base branch from master to 3.4 April 3, 2018 07:08
@javiereguiluz
Copy link
Member

Thanks a lot for this improvement! And congrats on your first Symfony Docs contribution

@javiereguiluz javiereguiluz merged commit 0dfcbd8 into symfony:3.4 Apr 3, 2018
javiereguiluz added a commit that referenced this pull request Apr 3, 2018
This PR was submitted for the master branch but it was squashed and merged into the 3.4 branch instead (closes #9528).

Discussion
----------

Replace jQuery example with plain JavaScript

The data attributes example relies unnecessarily on jQuery and is potentially more confusing because it masks how attributes actually work in JavaScript and it's another level of abstraction to deal with. It is a better idea to promote web standards here because people tend to copy what they see, so let's steer them in a future-friendly direction.

Commits
-------

0dfcbd8 Replace jQuery example with plain JavaScript
@msheakoski msheakoski deleted the plain-js-example branch April 4, 2018 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants