diff --git a/src/utils/bindProps.js b/src/utils/bindProps.js index cb888bc..593cec1 100644 --- a/src/utils/bindProps.js +++ b/src/utils/bindProps.js @@ -1,8 +1,5 @@ import WatchPrimitiveProperties from '../utils/WatchPrimitiveProperties' - -function capitalizeFirstLetter(string) { - return string.charAt(0).toUpperCase() + string.slice(1) -} +import {Str} from "./string"; export function getPropsValues(vueInst, props) { return Object.keys(props).reduce((acc, prop) => { @@ -26,8 +23,8 @@ export function bindProps(vueInst, googleMapsInst, props) { if (noBind) continue - const setMethodName = 'set' + capitalizeFirstLetter(attribute) - const getMethodName = 'get' + capitalizeFirstLetter(attribute) + const setMethodName = 'set' + Str.capitalizeFirstLetter(attribute) + const getMethodName = 'get' + Str.capitalizeFirstLetter(attribute) const eventName = attribute.toLowerCase() + '_changed' const initialValue = vueInst[attribute] @@ -42,8 +39,7 @@ export function bindProps(vueInst, googleMapsInst, props) { // although this may really be the user's responsibility if (type !== Object || !trackProperties) { // Track the object deeply - vueInst.$watch( - attribute, + vueInst.$watch(attribute, () => { const attributeValue = vueInst[attribute] diff --git a/src/utils/string.js b/src/utils/string.js new file mode 100644 index 0000000..830844d --- /dev/null +++ b/src/utils/string.js @@ -0,0 +1,5 @@ +export class Str { + static capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1) + } +}