model.ts — vue Source File
Architecture documentation for model.ts, a typescript file in the vue codebase. 4 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR fba67da2_5967_6779_f088_36da3dcbd363["model.ts"] a9349ba5_bc74_f03e_b748_41eb2dcc87a9["config"] fba67da2_5967_6779_f088_36da3dcbd363 --> a9349ba5_bc74_f03e_b748_41eb2dcc87a9 a53a30c8_9418_4cc4_6709_164fca9149e1["helpers"] fba67da2_5967_6779_f088_36da3dcbd363 --> a53a30c8_9418_4cc4_6709_164fca9149e1 f5b46d91_7fed_01a7_1b96_7cc89c6220e9["model"] fba67da2_5967_6779_f088_36da3dcbd363 --> f5b46d91_7fed_01a7_1b96_7cc89c6220e9 a80b8e3b_d720_9146_3bf6_594d4ee5dd77["compiler"] fba67da2_5967_6779_f088_36da3dcbd363 --> a80b8e3b_d720_9146_3bf6_594d4ee5dd77 f775a5be_e998_af45_9bda_1ef8cd715838["index.ts"] f775a5be_e998_af45_9bda_1ef8cd715838 --> fba67da2_5967_6779_f088_36da3dcbd363 style fba67da2_5967_6779_f088_36da3dcbd363 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import config from 'core/config'
import { addHandler, addProp, getBindingAttr } from 'compiler/helpers'
import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
import { ASTDirective, ASTElement, ASTModifiers } from 'types/compiler'
let warn
// in some cases, the event used has to be determined at runtime
// so we used some reserved tokens during compile.
export const RANGE_TOKEN = '__r'
export const CHECKBOX_RADIO_TOKEN = '__c'
export default function model(
el: ASTElement,
dir: ASTDirective,
_warn: Function
): boolean | undefined {
warn = _warn
const value = dir.value
const modifiers = dir.modifiers
const tag = el.tag
const type = el.attrsMap.type
if (__DEV__) {
// inputs with type="file" are read only and setting the input's
// value will throw an error.
if (tag === 'input' && type === 'file') {
warn(
`<${el.tag} v-model="${value}" type="file">:\n` +
`File inputs are read only. Use a v-on:change listener instead.`,
el.rawAttrsMap['v-model']
)
}
}
if (el.component) {
genComponentModel(el, value, modifiers)
// component v-model doesn't need extra runtime
return false
} else if (tag === 'select') {
genSelect(el, value, modifiers)
} else if (tag === 'input' && type === 'checkbox') {
genCheckboxModel(el, value, modifiers)
} else if (tag === 'input' && type === 'radio') {
genRadioModel(el, value, modifiers)
} else if (tag === 'input' || tag === 'textarea') {
genDefaultModel(el, value, modifiers)
} else if (!config.isReservedTag(tag)) {
genComponentModel(el, value, modifiers)
// component v-model doesn't need extra runtime
return false
} else if (__DEV__) {
warn(
`<${el.tag} v-model="${value}">: ` +
`v-model is not supported on this element type. ` +
"If you are working with contenteditable, it's recommended to " +
'wrap a library dedicated for that purpose inside a custom component.',
el.rawAttrsMap['v-model']
)
}
// ... (122 more lines)
Domain
Subdomains
Dependencies
- compiler
- config
- helpers
- model
Imported By
Source
Frequently Asked Questions
What does model.ts do?
model.ts is a source file in the vue codebase, written in typescript. It belongs to the WebPlatform domain, WebCompiler subdomain.
What functions are defined in model.ts?
model.ts defines 5 function(s): genCheckboxModel, genDefaultModel, genRadioModel, genSelect, model.
What does model.ts depend on?
model.ts imports 4 module(s): compiler, config, helpers, model.
What files import model.ts?
model.ts is imported by 1 file(s): index.ts.
Where is model.ts in the architecture?
model.ts is located at src/platforms/web/compiler/directives/model.ts (domain: WebPlatform, subdomain: WebCompiler, directory: src/platforms/web/compiler/directives).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free