Skip to content

Commit

Permalink
Merge pull request #112 from Aareksio/fix-module-size
Browse files Browse the repository at this point in the history
Replace lodash with homemade functions
  • Loading branch information
KABBOUCHI committed Nov 30, 2019
2 parents 3b26970 + a50dd31 commit 7b36e6b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -90,8 +90,6 @@
],
"dependencies": {
"humps": "^2.0.1",
"lodash.mapvalues": "^4.6.0",
"lodash.pickby": "^4.6.0",
"tippy.js": "^4.2.1"
}
}
29 changes: 18 additions & 11 deletions src/components/Tippy.vue
Expand Up @@ -14,8 +14,6 @@
import tippy from "tippy.js";
import humps from "humps";
import defaultProps, { booleanProps } from "../props";
import pickBy from "lodash.pickby";
import mapValues from "lodash.mapvalues";
export default {
props: [
"to",
Expand Down Expand Up @@ -102,22 +100,31 @@ export default {
tippy() {
return this.tip;
},
getOptions() {
this.options = humps.camelizeKeys(this.$attrs);
this.options = pickBy(this.options, (value, key) => {
return defaultProps.hasOwnProperty(key);
});
this.options = mapValues(this.options, (value, key) => {
filterOptions () {
const getValue = (key, value) => {
if (booleanProps.hasOwnProperty(key)) {
if (value === "") return true;
if (value === "false") return false;
if (value === "true") return true;
}
return value;
});
};
for (const key of Object.keys(this.options)) {
if (!defaultProps.hasOwnProperty(key)) {
// We're replacing this.options anyway, we don't have to worry about modifying the object
delete this.options[key];
}
this.options[key] = getValue(key, this.options[key]);
}
return this.options;
},
getOptions() {
this.options = humps.camelizeKeys(this.$attrs);
this.filterOptions();
if (!this.options.onShow && this.$listeners && this.$listeners["show"]) {
this.options.onShow = (...args) => {
Expand Down

0 comments on commit 7b36e6b

Please sign in to comment.