Skip to content

Commit 141c381

Browse files
committed
github-buttons 2.0.0
1 parent fd717da commit 141c381

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

index.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,40 @@ import { render } from 'github-buttons'
22

33
export default {
44
name: 'github-button',
5-
props: ['href', 'title', 'ariaLabel', 'dataIcon', 'dataSize', 'dataText', 'dataShowCount'],
5+
props: ['href', 'ariaLabel', 'title', 'dataIcon', 'dataSize', 'dataShowCount', 'dataText'],
66
render: function (h) {
77
return h('a', { attrs: {
8-
href: this.href,
9-
title: this.title,
8+
'href': this.href,
109
'aria-label': this.ariaLabel,
10+
'title': this.title,
1111
'data-icon': this.dataIcon,
1212
'data-size': this.dataSize,
13-
'data-text': this.dataText,
14-
'data-show-count': this.dataShowCount
13+
'data-show-count': this.dataShowCount,
14+
'data-text': this.dataText
1515
} }, this.$slots.default)
1616
},
1717
mounted: function () {
18-
render(this.$el.parentNode.insertBefore(this._ = document.createElement('span'), this.$el).appendChild(this.$el))
18+
this.render()
1919
},
2020
beforeUpdate: function () {
21-
this._.parentNode.replaceChild(this.$el, this._)
21+
this.reset()
2222
},
2323
updated: function () {
24-
render(this.$el.parentNode.insertBefore(this._ = document.createElement('span'), this.$el).appendChild(this.$el))
24+
this.render()
25+
},
26+
beforeDestroy: function () {
27+
this.reset()
28+
},
29+
methods: {
30+
render: function () {
31+
render(this.$el.parentNode.insertBefore(this._ = document.createElement('span'), this.$el).appendChild(this.$el), (function(_this) {
32+
return function (el) {
33+
_this.$el.parentNode.replaceChild(el, _this.$el)
34+
}
35+
})(this))
36+
},
37+
reset: function () {
38+
this._.parentNode.replaceChild(this.$el, this._)
39+
}
2540
}
2641
}

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
},
2424
"homepage": "https://github.com/ntkme/vue-github-button#readme",
2525
"dependencies": {
26-
"github-buttons": "^1.0.0"
26+
"github-buttons": "^2.0.0"
2727
}
2828
}

0 commit comments

Comments
 (0)