Skip to content

Commit 53d1174

Browse files
Updated component to no longer need to create an empty div to hold text. Updated example page.
1 parent db948bc commit 53d1174

11 files changed

+159
-230
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG.md
22

3+
## 1.0.6 (2019-01-01)
4+
5+
- Removed need to create actual div to hold the text - due to 3.0.1 `countable.js` update.
6+
37
## 1.0.5 (2018-11-03)
48

59
Features:

dist/vue-countable.esm.js

+8-27
Original file line numberDiff line numberDiff line change
@@ -46,43 +46,28 @@ var script = {
4646
watch: {
4747
text: {
4848
handler: function (value) {
49-
var this$1 = this;
50-
51-
var area = document.getElementById(this.elementId);
52-
if (!area) {
53-
return
54-
}
55-
56-
this.$nextTick(function () {
57-
this$1.countable.count(area, function (counter) {
58-
this$1.$emit('change', counter);
59-
}, this$1.options);
60-
});
49+
// Everytime this.text changes we'll update our live count
50+
this.init();
6151
}
6252
}
6353
},
6454
methods: {
65-
// The init function is important because we want to provide counts not
66-
// only during changes, but also on initialization.
6755
init: function init () {
6856
var this$1 = this;
6957

7058
// Set our countable instance
7159
this.countable = countable;
7260

73-
var area = document.getElementById(this.elementId);
74-
if (!area) {
75-
return
76-
}
77-
7861
this.$nextTick(function () {
79-
this$1.countable.count(area, function (counter) {
62+
this$1.countable.count(this$1.text, function (counter) {
8063
this$1.$emit('change', counter);
8164
}, this$1.options);
8265
});
8366
}
8467
},
8568
mounted: function mounted () {
69+
// The init function is important because we want to provide counts not
70+
// only during changes, but also on initialization.
8671
this.init();
8772
}
8873
}
@@ -95,23 +80,19 @@ var __vue_render__ = function() {
9580
var _vm = this;
9681
var _h = _vm.$createElement;
9782
var _c = _vm._self._c || _h;
98-
return _c(
99-
"div",
100-
{ staticClass: "countable-div", attrs: { id: _vm.elementId } },
101-
[_vm._v(_vm._s(_vm.text))]
102-
)
83+
return _c("div")
10384
};
10485
var __vue_staticRenderFns__ = [];
10586
__vue_render__._withStripped = true;
10687

10788
/* style */
10889
var __vue_inject_styles__ = function (inject) {
10990
if (!inject) { return }
110-
inject("data-v-7a4afb70_0", { source: "\n.countable-div[data-v-7a4afb70] {\n display: none;\n}\n\n/*# sourceMappingURL=vue-countable.vue.map */", map: {"version":3,"sources":["/Users/johndatserakis/Documents/Code/vue-countable/src/vue-countable.vue","vue-countable.vue"],"names":[],"mappings":";AA0FA;EACA,cAAA;CACA;;ACzFA,6CAA6C","file":"vue-countable.vue","sourcesContent":[null,".countable-div {\n display: none; }\n\n/*# sourceMappingURL=vue-countable.vue.map */"]}, media: undefined });
91+
inject("data-v-12d8198d_0", { source: "\n/*# sourceMappingURL=vue-countable.vue.map */", map: {"version":3,"sources":["vue-countable.vue"],"names":[],"mappings":";AACA,6CAA6C","file":"vue-countable.vue"}, media: undefined });
11192

11293
};
11394
/* scoped */
114-
var __vue_scope_id__ = "data-v-7a4afb70";
95+
var __vue_scope_id__ = "data-v-12d8198d";
11596
/* module identifier */
11697
var __vue_module_identifier__ = undefined;
11798
/* functional template */

dist/vue-countable.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-countable.umd.js

+8-27
Original file line numberDiff line numberDiff line change
@@ -52,43 +52,28 @@
5252
watch: {
5353
text: {
5454
handler: function (value) {
55-
var this$1 = this;
56-
57-
var area = document.getElementById(this.elementId);
58-
if (!area) {
59-
return
60-
}
61-
62-
this.$nextTick(function () {
63-
this$1.countable.count(area, function (counter) {
64-
this$1.$emit('change', counter);
65-
}, this$1.options);
66-
});
55+
// Everytime this.text changes we'll update our live count
56+
this.init();
6757
}
6858
}
6959
},
7060
methods: {
71-
// The init function is important because we want to provide counts not
72-
// only during changes, but also on initialization.
7361
init: function init () {
7462
var this$1 = this;
7563

7664
// Set our countable instance
7765
this.countable = countable;
7866

79-
var area = document.getElementById(this.elementId);
80-
if (!area) {
81-
return
82-
}
83-
8467
this.$nextTick(function () {
85-
this$1.countable.count(area, function (counter) {
68+
this$1.countable.count(this$1.text, function (counter) {
8669
this$1.$emit('change', counter);
8770
}, this$1.options);
8871
});
8972
}
9073
},
9174
mounted: function mounted () {
75+
// The init function is important because we want to provide counts not
76+
// only during changes, but also on initialization.
9277
this.init();
9378
}
9479
}
@@ -101,23 +86,19 @@
10186
var _vm = this;
10287
var _h = _vm.$createElement;
10388
var _c = _vm._self._c || _h;
104-
return _c(
105-
"div",
106-
{ staticClass: "countable-div", attrs: { id: _vm.elementId } },
107-
[_vm._v(_vm._s(_vm.text))]
108-
)
89+
return _c("div")
10990
};
11091
var __vue_staticRenderFns__ = [];
11192
__vue_render__._withStripped = true;
11293

11394
/* style */
11495
var __vue_inject_styles__ = function (inject) {
11596
if (!inject) { return }
116-
inject("data-v-7a4afb70_0", { source: "\n.countable-div[data-v-7a4afb70] {\n display: none;\n}\n\n/*# sourceMappingURL=vue-countable.vue.map */", map: {"version":3,"sources":["/Users/johndatserakis/Documents/Code/vue-countable/src/vue-countable.vue","vue-countable.vue"],"names":[],"mappings":";AA0FA;EACA,cAAA;CACA;;ACzFA,6CAA6C","file":"vue-countable.vue","sourcesContent":[null,".countable-div {\n display: none; }\n\n/*# sourceMappingURL=vue-countable.vue.map */"]}, media: undefined });
97+
inject("data-v-12d8198d_0", { source: "\n/*# sourceMappingURL=vue-countable.vue.map */", map: {"version":3,"sources":["vue-countable.vue"],"names":[],"mappings":";AACA,6CAA6C","file":"vue-countable.vue"}, media: undefined });
11798

11899
};
119100
/* scoped */
120-
var __vue_scope_id__ = "data-v-7a4afb70";
101+
var __vue_scope_id__ = "data-v-12d8198d";
121102
/* module identifier */
122103
var __vue_module_identifier__ = undefined;
123104
/* functional template */

0 commit comments

Comments
 (0)