Extract sting utility to an external function
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
import WatchPrimitiveProperties from '../utils/WatchPrimitiveProperties'
|
import WatchPrimitiveProperties from '../utils/WatchPrimitiveProperties'
|
||||||
|
import {Str} from "./string";
|
||||||
function capitalizeFirstLetter(string) {
|
|
||||||
return string.charAt(0).toUpperCase() + string.slice(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getPropsValues(vueInst, props) {
|
export function getPropsValues(vueInst, props) {
|
||||||
return Object.keys(props).reduce((acc, prop) => {
|
return Object.keys(props).reduce((acc, prop) => {
|
||||||
@@ -26,8 +23,8 @@ export function bindProps(vueInst, googleMapsInst, props) {
|
|||||||
|
|
||||||
if (noBind) continue
|
if (noBind) continue
|
||||||
|
|
||||||
const setMethodName = 'set' + capitalizeFirstLetter(attribute)
|
const setMethodName = 'set' + Str.capitalizeFirstLetter(attribute)
|
||||||
const getMethodName = 'get' + capitalizeFirstLetter(attribute)
|
const getMethodName = 'get' + Str.capitalizeFirstLetter(attribute)
|
||||||
const eventName = attribute.toLowerCase() + '_changed'
|
const eventName = attribute.toLowerCase() + '_changed'
|
||||||
const initialValue = vueInst[attribute]
|
const initialValue = vueInst[attribute]
|
||||||
|
|
||||||
@@ -42,8 +39,7 @@ export function bindProps(vueInst, googleMapsInst, props) {
|
|||||||
// although this may really be the user's responsibility
|
// although this may really be the user's responsibility
|
||||||
if (type !== Object || !trackProperties) {
|
if (type !== Object || !trackProperties) {
|
||||||
// Track the object deeply
|
// Track the object deeply
|
||||||
vueInst.$watch(
|
vueInst.$watch(attribute,
|
||||||
attribute,
|
|
||||||
() => {
|
() => {
|
||||||
const attributeValue = vueInst[attribute]
|
const attributeValue = vueInst[attribute]
|
||||||
|
|
||||||
|
|||||||
5
src/utils/string.js
Normal file
5
src/utils/string.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export class Str {
|
||||||
|
static capitalizeFirstLetter(string) {
|
||||||
|
return string.charAt(0).toUpperCase() + string.slice(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user