faster classname function

This commit is contained in:
Nolan Lawson 2018-03-14 18:52:33 -07:00
parent 2db30856f9
commit 1477fbfbda
3 changed files with 23 additions and 4 deletions

View file

@ -60,16 +60,19 @@
}
</style>
<script>
import { classname } from '../_utils/classname'
export default {
computed: {
computedClass: (pressable, pressed, big, className) => {
return [
return classname(
'icon-button',
!pressable && 'not-pressable',
pressed && 'pressed',
big && 'big-icon',
className
].filter(Boolean).join(' ')
)
}
}
}

View file

@ -94,6 +94,7 @@
import { store } from '../../_store/store'
import { goto } from 'sapper/runtime.js'
import { registerClickDelegate, unregisterClickDelegate } from '../../_utils/delegate'
import { classname } from '../../_utils/classname'
export default {
oncreate() {
@ -124,11 +125,11 @@
store: () => store,
helpers: {
getClasses(originalStatus, timelineType, isStatusInOwnThread) {
return [
return classname(
originalStatus.visibility === 'direct' && 'status-direct',
timelineType !== 'search' && 'status-in-timeline',
isStatusInOwnThread && 'status-in-own-thread'
].filter(Boolean).join(' ')
)
}
},
methods: {

View file

@ -0,0 +1,15 @@
export function classname () {
let res = ''
let len = arguments.length
let i = -1
while (++i < len) {
let item = arguments[i]
if (item) {
if (res) {
res += ' '
}
res += item
}
}
return res
}