Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.3k
Support for wildcard attributes, implement data-* attribute#237
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
08f62638f2d3c254c9ef5ec666eba4bb578File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = '0.21.0' | ||
| __version__ = '0.21.1' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -17,6 +17,7 @@ | ||
| Component._prop_names = ('id', 'a', 'children', 'style', ) | ||
| Component._type = 'TestComponent' | ||
| Component._namespace = 'test_namespace' | ||
| Component._valid_wildcard_attributes = ['data-', 'aria-'] | ||
| def nested_tree(): | ||
| @@ -411,6 +412,25 @@ def to_dict(id, children): | ||
| ) | ||
| """ | ||
| def test_to_plotly_json_with_wildcards(self): | ||
| c = Component(id='a', **{'aria-expanded': 'true', | ||
| 'data-toggle': 'toggled', | ||
| 'data-none': None}) | ||
| c._prop_names = ('id',) | ||
| c._type = 'MyComponent' | ||
| c._namespace = 'basic' | ||
| self.assertEqual( | ||
| c.to_plotly_json(), | ||
| {'namespace': 'basic', | ||
| 'props': { | ||
| 'aria-expanded': 'true', | ||
| 'data-toggle': 'toggled', | ||
| 'data-none': None, | ||
| 'id': 'a', | ||
| }, | ||
| 'type': 'MyComponent'} | ||
| ) | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 | ||
| def test_len(self): | ||
| self.assertEqual(len(Component()), 0) | ||
| self.assertEqual(len(Component(children='Hello World')), 1) | ||
| @@ -580,6 +600,16 @@ def test_repr_nested_arguments(self): | ||
| "Table(Table(children=Table(id='1'), id='2'))" | ||
| ) | ||
| def test_repr_with_wildcards(self): | ||
| c = self.ComponentClass(id='1', **{"data-one": "one", | ||
| "aria-two": "two"}) | ||
| data_first = "Table(id='1', data-one='one', aria-two='two')" | ||
| aria_first = "Table(id='1', aria-two='two', data-one='one')" | ||
| repr_string = repr(c) | ||
| if not (repr_string == data_first or repr_string == aria_first): | ||
| raise Exception("%s\nDoes not equal\n%s\nor\n%s" % | ||
| (repr_string, data_first, aria_first)) | ||
| def test_docstring(self): | ||
| assert_docstring(self.assertEqual, self.ComponentClass.__doc__) | ||
| @@ -674,6 +704,10 @@ def setUp(self): | ||
| ['customArrayProp', 'list'], | ||
| ['data-*', 'string'], | ||
| ['aria-*', 'string'], | ||
| ['id', 'string'], | ||
| ['dashEvents', "a value equal to: 'restyle', 'relayout', 'click'"] | ||
| @@ -749,6 +783,8 @@ def assert_docstring(assertEqual, docstring): | ||
| "- customProp (optional)", | ||
| "- customArrayProp (list; optional)", | ||
| '- data-* (string; optional)', | ||
| '- aria-* (string; optional)', | ||
| '- id (string; optional)', | ||
| '', | ||
| "Available events: 'restyle', 'relayout', 'click'", | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, way better 👍