Skip to content
Permalink
Browse files

fix: bind all listeners

  • Loading branch information...
egoist committed Jan 11, 2019
1 parent ce94c85 commit 96c7ae900eb41063e6655dde1c6a08ef12f1e2ff
@@ -4,6 +4,12 @@ const posthtml = require('posthtml')
const STYLE_COMPONENT = path.join(__dirname, './lib/StyleComponent.js')

const plugin = state => tree => {
tree.match({ tag: 'svg' }, node => {
node.attrs = node.attrs || {}
// Bind all events so that you can @click="handler" instead of @click.native="handler"
node.attrs['v-on'] = '$listeners'
return node
})
// SVGO will inline styles, so if you don't turn off relevant plugin
// the tree will never match `style` nodes because they don't exist
tree.match({ tag: 'style' }, node => {
@@ -11,7 +11,7 @@ Generated by [AVA](https://ava.li).
{
component: `<template>␊
<svg width="48px" height="1px" viewBox="0 0 48 1" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">␊
<svg width="48px" height="1px" viewBox="0 0 48 1" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" v-on="$listeners">␊
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->␊
<title>Rectangle 5 可以</title>␊
<desc>Created with Sketch.</desc>␊
BIN +10 Bytes (100%) test/snapshots/index.test.js.snap
Binary file not shown.
@@ -8,4 +8,4 @@ Generated by [AVA](https://ava.li).

> Snapshot 1
'<template><svg id="foo_svg__foo" width="48" height="1" viewBox="0 0 48 1" version="1.1" xmlns="http://www.w3.org/2000/svg"><g id="foo_svg__Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="foo_svg__19-Separator" transform="translate(-129 -156)" fill="#063855"><g id="foo_svg__Controls/Settings" transform="translate(80)"><g id="foo_svg__Content" transform="translate(0 64)"><g id="foo_svg__Group" transform="translate(24 56)"><g id="foo_svg__Group-2"><path id="foo_svg__Rectangle-5" d="M25 36h48v1H25z"></path></g></g></g></g></g></g></svg></template>'
'<template><svg id="foo_svg__foo" width="48" height="1" viewBox="0 0 48 1" version="1.1" xmlns="http://www.w3.org/2000/svg" v-on="$listeners"><g id="foo_svg__Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="foo_svg__19-Separator" transform="translate(-129 -156)" fill="#063855"><g id="foo_svg__Controls/Settings" transform="translate(80)"><g id="foo_svg__Content" transform="translate(0 64)"><g id="foo_svg__Group" transform="translate(24 56)"><g id="foo_svg__Group-2"><path id="foo_svg__Rectangle-5" d="M25 36h48v1H25z"></path></g></g></g></g></g></g></svg></template>'
BIN +10 Bytes (100%) test/snapshots/loader.test.js.snap
Binary file not shown.

0 comments on commit 96c7ae9

Please sign in to comment.
You can’t perform that action at this time.