// e.g.
// - createObjectMatcher({ 'foo': '[bar]' }) matches { foo: bar }
// - createObjectMatcher({ '[foo]': 'bar' }) matches { [foo]: "bar" }
-export function createObjectMatcher(obj: any) {
+export function createObjectMatcher(obj: Record<string, any>) {
return {
type: NodeTypes.JS_OBJECT_EXPRESSION,
properties: Object.keys(obj).map(key => ({
interface HTMLAttributes {
class?: any
- style?: string | { [key: string]: string | number }
+ style?: string | Partial<CSSStyleDeclaration>
accesskey?: string
contenteditable?: boolean
contextmenu?: string
import { isString } from '@vue/shared'
-export function patchStyle(el: any, prev: any, next: any) {
- const { style } = el
+type Style = string | Partial<CSSStyleDeclaration> | null
+
+export function patchStyle(el: Element, prev: Style, next: Style) {
+ const style = (el as HTMLElement).style
if (!next) {
el.removeAttribute('style')
} else if (isString(next)) {
style.cssText = next
} else {
for (const key in next) {
- style[key] = next[key]
+ style[key] = next[key] as string
}
if (prev && !isString(prev)) {
for (const key in prev) {
fn: T,
delay: number = 300
): T {
- let prevTimer: NodeJS.Timeout | null = null
+ let prevTimer: number | null = null
return ((...args: any[]) => {
if (prevTimer) {
clearTimeout(prevTimer)
}
- prevTimer = setTimeout(() => {
+ prevTimer = window.setTimeout(() => {
fn(...args)
prevTimer = null
}, delay)