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

Fix create_attribute function #54

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MichaelAllenWarner
Copy link

This PR gets the create_attributes() function working correctly in both Twig.js and Twing. Specifically, it:

Here are the main changes:

  • The lib/Attribute.js file now uses a new "in-between" class that makes the drupal-attribute npm package compatible with both Twing and Twig.js.
  • The lib/functions/create_attribute/definition.js file has been greatly simplified accordingly.
  • The tests that were there to ensure that lib/Attribute.js default-exported the class from the drupal-attribute package have been removed (since that file now default-exports the "in-between" class instead).
  • All previously-test.failing() tests in tests/Twig.js/functions/create_attribute.js and tests/Twing/functions/create_attribute.js have been changed to test() and now pass.

Some notes:

  • Incorrect .addClass("class1", "class2") syntax in the attribute-method tests has been fixed (should be .addClass(["class1", "class2"]), with the array).
  • The property-access tests now check not only for the id attribute but also for class, since the latter is a special case that's handled differently in the code.
  • In the (now-passing) constructor test in tests/Twig.js/functions/create_attribute.js, the attributes print in the opposite order than expected (i.e., id comes before class in the constructor argument, but class prints before id in the rendered string). That makes no difference to a browser, but I did make a comment about it in the file.
  • I've added a test.failing() test at the end of both tests/Twig.js/functions/create_attribute.js and tests/Twing/functions/create_attribute.js to acknowledge that the without filter isn't working with attributes right now but is supposed to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant