Skip to content
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

possible to specify options via data- attributes #48

Merged
merged 1 commit into from
Jul 28, 2014

Conversation

tengyifei
Copy link
Contributor

Hi, it seems that jquery.find returns an array instead of a single element. This prevented textillate from reading the options specified in the

  • elements.

    This patch fixes that error. Also, it converts "true"/"false" to true/false in the case of data-in-shuffle etc., and handles situation where data-in-delayScale is forcibly changed to lower case. This makes it possible to specify those options as well.

  • @@ -25,14 +25,21 @@
    if (!attrs.length) return data;

    $.each(attrs, function (i, attr) {
    if (/^data-in-*/.test(attr.nodeName)) {

    function stringToBoolean(str) {
    Copy link
    Owner

    Choose a reason for hiding this comment

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

    I would be better to move stringToBoolean to the top level scope (the same as isInEffect/isOutEffect ) so it isn't being continuously redefined.

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    IMHO, in modern browsers, the function will only be parsed once. Being repeatedly redefined does not incur additional load on the JavaScript engine. This MDN document mentioned about it at around 3/5 down the article. I wrote it this way as it seemed neater, as in the getData function can be self-contained.

    @jschr
    Copy link
    Owner

    jschr commented Jul 25, 2014

    Thanks for this, just a couple minor comments but looks good!

    @tengyifei
    Copy link
    Contributor Author

    Hi, I explained my reasoning behind some of the changes. Kindly refer to the line notes.

    jschr pushed a commit that referenced this pull request Jul 28, 2014
    possible to specify options via data- attributes
    @jschr jschr merged commit 4d6914d into jschr:master Jul 28, 2014
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants