Skip to content

Add preventDefault option to event bindings#148

Merged
brianmhunt merged 6 commits into
knockout:mainfrom
bandcampdotcom:preventDefault
Jul 21, 2021
Merged

Add preventDefault option to event bindings#148
brianmhunt merged 6 commits into
knockout:mainfrom
bandcampdotcom:preventDefault

Conversation

@danieldickison

Copy link
Copy Markdown
Collaborator

Here's my attempt at #147 to add a preventDefault option to event bindings, as an alternative to having the handler function return a boolean.

@brianmhunt brianmhunt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this, looks like there's a few minor things and this would be ok to merge.

Comment thread packages/binding.core/spec/eventBehaviors.ts Outdated
Comment thread packages/binding.core/spec/eventBehaviors.ts
Comment thread packages/binding.core/spec/eventBehaviors.ts
Comment thread packages/binding.core/src/event.ts Outdated
Comment thread packages/binding.core/src/event.ts

@brianmhunt brianmhunt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

Sorry the CI tests don't run automatically on commit, but I trust the tests pass as expected.

Feel free to merge.

On a release plan, I'm working on a Github action for releases. Note that it'll be with esbuild, which is not as well tested as the rollup version, so I'll be starting with 4.1.0... release tags.

})

it('Should allow default action by setting preventDefault:false', function () {
testNode.innerHTML = "<div data-bind='event: {click: test}'><a href='#' data-bind='event: {click: {preventDefault: false}}'>hey</a></div>"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could also test preventDefault: true here, though the code path for that is identical to the unwrap() tested below so I'm not concerned.

@danieldickison

Copy link
Copy Markdown
Collaborator Author

Feel free to merge.

Am I able to merge this into the upstream myself? I assumed you'd need to initiate that merge. (Sorry, I'm not too familiar with the workflow in github.)

@brianmhunt
brianmhunt merged commit b126092 into knockout:main Jul 21, 2021
@brianmhunt

Copy link
Copy Markdown
Member

Am I able to merge this into the upstream myself? I assumed you'd need to initiate that merge. (Sorry, I'm not too familiar with the workflow in github.)

I'm not sure. 😄 I merged it in any case, now.

@danieldickison
danieldickison deleted the preventDefault branch July 21, 2021 00:49
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