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 the draggable attribute & flesh out enumerated property support. #216

Merged
merged 4 commits into from
Sep 24, 2018

Conversation

alexjeffburke
Copy link
Member

The dragabble attribute was not being correctly recognised - when
specified it must have only two values, the strings "true" and
"false". Previously it was treated as a boolean attribute, which
lead to true being accepted while false did not work at all.

Change this so the only acceptable values are the two supported
strings. Add some belt and braces when specifying the value in an
object spec so you cannot accidentally specify an unsupported value.

The dragabble attribute was not being correctly recognised - when
specified it must have only two values, the strings "true" and
"false". Previously it was treated as a boolean attribute, which
lead to true being accepted while false did not work at all.

Change this so the only acceptable values are the two supported
strings. Add some belt and braces when specifying the value in an
object spec so you cannot accidentally specify an unsupported value.
@alexjeffburke alexjeffburke force-pushed the feature/supportEnumeratedDraggableAttribute branch from d00e763 to 43fc8d9 Compare September 24, 2018 17:56
@alexjeffburke
Copy link
Member Author

alexjeffburke commented Sep 24, 2018

@sunesimonsen this actually affects unexpected-reaction - I had a test here that failed because we used the HTML5 DnD backend, something ended up with a draggable attribute and it didn't work.

I've looked into the HTML5 spec and the draggable property cannot be treated as a boolean - despite using true/false the value must be fully specified as for example draggable="true". There also seem to be other attributes that might need this treatment so I've tried to lay that groundwork.

In order to make sure we're still being helpful, should you accidentally specify false as the value (where in actual fact is must be "false"), I've added a custom error message that tells you what the supported values are. Given I messed this up while writing the tests and just couldn't see it at all, I thought the extra message was worthwhile.

lib/index.js Outdated
.appendInspected(
enumeratedAttributeValues[attributeName]
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it really necessary to state the supported values?

Copy link
Member

Choose a reason for hiding this comment

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

If we are going to do this, we shoudn't use withError inside bubbleError as bubbleError is just sugar for withError. We should just set the error mode on the error directly.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry - I see this is just another sanity check. Then we should just change the bubbleError code.

@sunesimonsen
Copy link
Member

Very nice find and great with a PR - thanks.

Copy link
Member

@sunesimonsen sunesimonsen left a comment

Choose a reason for hiding this comment

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

👍 I have thrown a few commits on top - hope that is okay :-)

@alexjeffburke
Copy link
Member Author

@sunesimonsen thanks for picking it up! I wasn't sure I got rhebputput portion totally right but wanted to get a fix together. Hope the supported values thing made sense, just felt like it might be a nasty footgun otherwise. Having a quick look at your additions now :)

@alexjeffburke
Copy link
Member Author

Particularly like the small output tweak to remove the array syntax - no room for confusion now 👍

@sunesimonsen sunesimonsen merged commit 961627a into master Sep 24, 2018
@sunesimonsen sunesimonsen deleted the feature/supportEnumeratedDraggableAttribute branch September 24, 2018 21:12
@sunesimonsen
Copy link
Member

Released as unexpected-dom@4.6.3

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.

3 participants