import { PatchFlags } from '@vue/shared'
export const transformIf: NodeTransform = createStructuralDirectiveTransform(
- /^(if|else|else-if)$/,
+ /^(?:if|else|else-if)$/,
(node, dir, context) => {
return processIf(node, dir, context, (ifNode, branch, isRoot) => {
// #1587: We need to dynamically increment the key based on the current
),
)
} else if (
- (vElse = findDir(slotElement, /^else(-if)?$/, true /* allowEmpty */))
+ (vElse = findDir(slotElement, /^else(?:-if)?$/, true /* allowEmpty */))
) {
// find adjacent v-if
let j = i
break
}
}
- if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
+ if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
__TEST__ && assert(dynamicSlots.length > 0)
// attach this slot to previous conditional
let conditional = dynamicSlots[
) => boolean = __BROWSER__ ? isMemberExpressionBrowser : isMemberExpressionNode
const fnExpRE =
- /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/
+ /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/
export const isFnExpressionBrowser: (exp: ExpressionNode) => boolean = exp =>
fnExpRE.test(getExpSource(exp))
}
}
-const dataAriaRE = /^(data|aria)-/
+const dataAriaRE = /^(?:data|aria)-/
const isStringifiableAttr = (name: string, ns: Namespaces) => {
return (
(ns === Namespaces.HTML
import selectorParser from 'postcss-selector-parser'
import { warn } from '../warn'
-const animationNameRE = /^(-\w+-)?animation-name$/
-const animationRE = /^(-\w+-)?animation$/
+const animationNameRE = /^(?:-\w+-)?animation-name$/
+const animationRE = /^(?:-\w+-)?animation$/
const keyframesRE = /^(?:-\w+-)?keyframes$/
const scopedPlugin: PluginCreator<string> = (id = '') => {
return firstChar === '.' || firstChar === '~' || firstChar === '@'
}
-const externalRE = /^(https?:)?\/\//
+const externalRE = /^(?:https?:)?\/\//
export function isExternalUrl(url: string): boolean {
return externalRE.test(url)
}
// Plugin for the first transform pass, which simply constructs the AST node
export const ssrTransformIf: NodeTransform = createStructuralDirectiveTransform(
- /^(if|else|else-if)$/,
+ /^(?:if|else|else-if)$/,
processIf,
)
if (__DEV__) {
for (let i = 0; i < container.attributes.length; i++) {
const attr = container.attributes[i]
- if (attr.name !== 'v-cloak' && /^(v-|:|@)/.test(attr.name)) {
+ if (attr.name !== 'v-cloak' && /^(?:v-|:|@)/.test(attr.name)) {
warnDeprecation(DeprecationTypes.GLOBAL_MOUNT_CONTAINER, null)
break
}
}
}
-const classifyRE = /(?:^|[-_])(\w)/g
+const classifyRE = /(?:^|[-_])\w/g
const classify = (str: string): string =>
str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '')
}
const hasTransform =
type === TRANSITION &&
- /\b(transform|all)(,|$)/.test(
+ /\b(?:transform|all)(?:,|$)/.test(
getStyleProperties(`${TRANSITION}Property`).toString(),
)
return {
if (e && e.target !== el) {
return
}
- if (!e || /transform$/.test(e.propertyName)) {
+ if (!e || e.propertyName.endsWith('transform')) {
el.removeEventListener('transitionend', cb)
;(el as any)[moveCbKey] = null
removeTransitionClass(el, moveClass)
if (__COMPAT__ && __DEV__ && container.nodeType === 1) {
for (let i = 0; i < (container as Element).attributes.length; i++) {
const attr = (container as Element).attributes[i]
- if (attr.name !== 'v-cloak' && /^(v-|:|@)/.test(attr.name)) {
+ if (attr.name !== 'v-cloak' && /^(?:v-|:|@)/.test(attr.name)) {
compatUtils.warnDeprecation(
DeprecationTypes.GLOBAL_MOUNT_CONTAINER,
null,
type Style = string | Record<string, string | string[]> | null
-const displayRE = /(^|;)\s*display\s*:/
+const displayRE = /(?:^|;)\s*display\s*:/
export function patchStyle(el: Element, prev: Style, next: Style): void {
const style = (el as HTMLElement).style
}) as T
}
-const camelizeRE = /-(\w)/g
+const camelizeRE = /-\w/g
/**
* @private
*/
export const camelize: (str: string) => string = cacheStringFunction(
(str: string): string => {
- return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''))
+ return str.replace(camelizeRE, c => c.slice(1).toUpperCase())
},
)