第一
This commit is contained in:
@@ -6,7 +6,7 @@ import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
|
||||
import * as runtimeDom from '@vue/runtime-dom'
|
||||
import { isString, NOOP, generateCodeFrame, extend } from '@vue/shared'
|
||||
import { InternalRenderFunction } from 'packages/runtime-core/src/component'
|
||||
|
||||
// 判断是不是调试模式
|
||||
if (__DEV__) {
|
||||
initDev()
|
||||
}
|
||||
@@ -17,21 +17,27 @@ function compileToFunction(
|
||||
template: string | HTMLElement,
|
||||
options?: CompilerOptions
|
||||
): RenderFunction {
|
||||
// 判断是不是字符串
|
||||
if (!isString(template)) {
|
||||
// 不是字符串判断下有没有nodeType属性
|
||||
if (template.nodeType) {
|
||||
// 获取内部的html代码
|
||||
template = template.innerHTML
|
||||
} else {
|
||||
// 报错 返回空函数
|
||||
__DEV__ && warn(`invalid template option: `, template)
|
||||
return NOOP
|
||||
}
|
||||
}
|
||||
|
||||
// key 等于传入末班
|
||||
const key = template
|
||||
// 获取缓存 ??
|
||||
const cached = compileCache[key]
|
||||
// 有直接返回缓存
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
|
||||
// 判断是不是id
|
||||
if (template[0] === '#') {
|
||||
const el = document.querySelector(template)
|
||||
if (__DEV__ && !el) {
|
||||
@@ -43,7 +49,10 @@ function compileToFunction(
|
||||
// by the server, the template should not contain any user data.
|
||||
template = el ? el.innerHTML : ``
|
||||
}
|
||||
|
||||
// 合并传入的选项
|
||||
// 添加 hoistStatic
|
||||
// onError
|
||||
// onWarn
|
||||
const opts = extend(
|
||||
{
|
||||
hoistStatic: true,
|
||||
@@ -52,7 +61,9 @@ function compileToFunction(
|
||||
} as CompilerOptions,
|
||||
options
|
||||
)
|
||||
|
||||
// ?? 不知道这个是干啥的
|
||||
// 根不执行
|
||||
console.log(opts.isCustomElement,customElements)
|
||||
if (!opts.isCustomElement && typeof customElements !== 'undefined') {
|
||||
opts.isCustomElement = tag => !!customElements.get(tag)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user