Skip to content

Fix methods for create_attribute() in Twing, and tweak some tests accordingly #53

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

Conversation

MichaelAllenWarner
Copy link

This PR modifies /lib/Attribute.js so that the create_attribute() function correctly returns an Attribute object with methods in Twing.

It also:

  • modifies the corresponding 'should return an Attribute object with methods' test (for both Twig.js and Twing) to use .addClass(["class1", "class2"]) instead of .addClass("class1", "class2") (according to the Drupal docs, an array should be used here for multiple classes);
  • changes test.failing(...) to test(...) for the Twing 'should return an Attribute object with methods' test;
  • accounts for the now-failing 'should export drupal-attribute as Attribute' tests by changing test(...) to test.failing(...) (perhaps it would be better to remove them altogether if this PR is accepted);
  • changes test(...) to test.failing(...) for the Twing 'should return an Attribute object with accessible properties' test, which is now failing (as the Twig.js one already was).

The last item (property-access now failing on Attribute objects in Twing) is clearly undesirable, and off-hand I'm not sure how to fix it, but in my experience the methods are far more commonly used than property access, so this strikes me as a good trade-off. Property-access can be tackled later separately.

Fixes #51

@MichaelAllenWarner MichaelAllenWarner changed the title refactor Attribute, and tweak some tests accordingly Fix methods for create_attribute() in Twing, and tweak some tests accordingly Apr 13, 2023
@MichaelAllenWarner
Copy link
Author

Closing in favor of #54 (which includes this work)

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.

In Twing, the object returned by create_attribute() doesn't have working methods
1 participant