Server : nginx/1.18.0 System : Linux localhost 6.14.3-x86_64-linode168 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 19:47:55 EDT 2025 x86_64 User : www-data ( 33) PHP Version : 8.0.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/ecommerce/node_modules/vue/src/platforms/web/server/modules/ |
/* @flow */
import { escape } from '../util'
import {
isDef,
isUndef,
extend
} from 'shared/util'
import {
isBooleanAttr,
isEnumeratedAttr,
isFalsyAttrValue,
convertEnumeratedValue
} from 'web/util/attrs'
import { isSSRUnsafeAttr } from 'web/server/util'
export default function renderAttrs (node: VNodeWithData): string {
let attrs = node.data.attrs
let res = ''
const opts = node.parent && node.parent.componentOptions
if (isUndef(opts) || opts.Ctor.options.inheritAttrs !== false) {
let parent = node.parent
while (isDef(parent)) {
// Stop fallthrough in case parent has inheritAttrs option set to false
if (parent.componentOptions && parent.componentOptions.Ctor.options.inheritAttrs === false) {
break;
}
if (isDef(parent.data) && isDef(parent.data.attrs)) {
attrs = extend(extend({}, attrs), parent.data.attrs)
}
parent = parent.parent
}
}
if (isUndef(attrs)) {
return res
}
for (const key in attrs) {
if (isSSRUnsafeAttr(key)) {
continue
}
if (key === 'style') {
// leave it to the style module
continue
}
res += renderAttr(key, attrs[key])
}
return res
}
export function renderAttr (key: string, value: string): string {
if (isBooleanAttr(key)) {
if (!isFalsyAttrValue(value)) {
return ` ${key}="${key}"`
}
} else if (isEnumeratedAttr(key)) {
return ` ${key}="${escape(convertEnumeratedValue(key, value))}"`
} else if (!isFalsyAttrValue(value)) {
return ` ${key}="${escape(String(value))}"`
}
return ''
}