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(playground): always set language to trigger the tree-sitter language onChange event #12

Merged
merged 2 commits into from
Oct 1, 2020

Conversation

IWANABETHATGUY
Copy link
Contributor

@IWANABETHATGUY IWANABETHATGUY commented Sep 30, 2020

Closes #8

set default language to yaml by js, because use html set the default select value does't trigger the tree-sitter.js onChange event

set default language to `yaml` by `js`, because use html set the default select value  does't trigger  the `tree-sitter.js` onChange event
@IWANABETHATGUY
Copy link
Contributor Author

Closes #8

docs/index.html Outdated
@@ -117,3 +117,8 @@ <h4>Tree</h4>
src="https://code.jquery.com/jquery-3.3.1.min.js"
crossorigin="anonymous">
</script>
<script>
let select = document.getElementById('language-select')
select.nodeValue = 'yaml'
Copy link
Owner

Choose a reason for hiding this comment

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

The event is registered via addEventListener, so we probably need to use dispatchEvent to trigger it:

Suggested change
select.nodeValue = 'yaml'
select.value = 'yaml'
select.dispatchEvent(new Event('change'))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just change the value is enough, i have try it.

Copy link
Owner

Choose a reason for hiding this comment

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

Can you share the steps to reproduce & verify? Only changing the value does not seem to work on my machine (Chrome on macOS).

@ikatyang ikatyang changed the title fix : https://github.com/ikatyang/tree-sitter-yaml/issues/8 fix(playground): always set language to trigger the tree-sitter language onChange event Oct 1, 2020
@ikatyang ikatyang merged commit a9e323c into ikatyang:master Oct 1, 2020
@ikatyang
Copy link
Owner

ikatyang commented Oct 1, 2020

Thanks!

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.

playground error
2 participants