/* @flow */ import { makeMap } from 'shared/util' const isAttr = makeMap( 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' + 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' + 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' + 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' + 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' + 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' + 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' + 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' + 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' + 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' + 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' + 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' + 'target,title,type,usemap,value,width,wrap' ) const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/ // eslint-disable-line no-control-regex export const isSSRUnsafeAttr = (name: string): boolean => { return unsafeAttrCharRE.test(name) } /* istanbul ignore next */ const isRenderableAttr = (name: string): boolean => { return ( isAttr(name) || name.indexOf('data-') === 0 || name.indexOf('aria-') === 0
const ncname = '[a-zA-Z_][\\w\\-\\.]*' const qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')' const startTagOpen = new RegExp('^<' + qnameCapture) const startTagClose = /^\s*(\/?)>/ const endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>') const doctype = /^<!DOCTYPE [^>]+>/i const comment = /^<!--/ const conditionalComment = /^<!\[/ let IS_REGEX_CAPTURING_BROKEN = false 'x'.replace(/x(.)?/g, function (m, g) { IS_REGEX_CAPTURING_BROKEN = g === '' }) // Special Elements (can contain anything) const isPlainTextElement = makeMap('script,style,textarea', true) const reCache = {} const decodingMap = { '<': '<', '>': '>', '"': '"', '&': '&', ' ': '\n' } const encodedAttr = /&(?:lt|gt|quot|amp);/g const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g function decodeAttr (value, shouldDecodeNewlines) { const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr return value.replace(re, match => decodingMap[match])
import { inBrowser } from 'core/util/env' import { makeMap } from 'shared/util' export const namespaceMap = { svg: 'http://www.w3.org/2000/svg', math: 'http://www.w3.org/1998/Math/MathML' } export const isReservedTag = makeMap( 'html,base,head,link,meta,style,title,' + 'address,article,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' + 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' + 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' + 'embed,object,param,source,canvas,script,noscript,del,ins,' + 'caption,col,colgroup,table,thead,tbody,td,th,tr,' + 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + 'output,progress,select,textarea,' + 'details,dialog,menu,menuitem,summary,' + 'content,element,shadow,template' ) export const isUnaryTag = makeMap( 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + 'link,meta,param,source,track,wbr', true ) // Elements that you can, intentionally, leave open // (and which close themselves)
const ncname = '[a-zA-Z_][\\w\\-\\.]*' const qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')' const startTagOpen = new RegExp('^<' + qnameCapture) const startTagClose = /^\s*(\/?)>/ const endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>') const doctype = /^<!DOCTYPE [^>]+>/i const comment = /^<!--/ const conditionalComment = /^<!\[/ let IS_REGEX_CAPTURING_BROKEN = false 'x'.replace(/x(.)?/g, function (m, g) { IS_REGEX_CAPTURING_BROKEN = g === '' }) // Special Elements (can contain anything) const isScriptOrStyle = makeMap('script,style', true) const hasLang = attr => attr.name === 'lang' && attr.value !== 'html' const isSpecialTag = (tag, isSFC, stack) => { if (isScriptOrStyle(tag)) { return true } if (isSFC && stack.length === 1) { // top-level template that has no pre-processor if (tag === 'template' && !stack[0].attrs.some(hasLang)) { return false } else { return true } } return false }
/* @flow */ import deindent from 'de-indent' import { parseHTML } from 'compiler/parser/html-parser' import { makeMap } from 'shared/util' const splitRE = /\r?\n/g const replaceRE = /./g const isSpecialTag = makeMap('script,style,template', true) type Attribute = { name: string, value: string }; /** * Parse a single-file component (*.vue) file into an SFC Descriptor Object. */ export function parseComponent ( content: string, options?: Object = {} ): SFCDescriptor { const sfc: SFCDescriptor = { template: null, script: null, styles: [], customBlocks: [] } let depth = 0 let currentBlock: ?(SFCBlock | SFCCustomBlock) = null
function genStaticKeys (keys: string): Function { return makeMap( 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' + (keys ? ',' + keys : '') ) }
import { isKnownView, getViewMeta } from '../element-registry' import { makeMap, once } from 'shared/util' export const isReservedTag = makeMap('template', true) let _Vue export function setVue(Vue) { _Vue = Vue } export const canBeLeftOpenTag = function(el) { return getViewMeta(el).canBeLeftOpenTag } export const isUnaryTag = function(el) { return getViewMeta(el).isUnaryTag } export function mustUseProp() { // console.log('mustUseProp') } export function getTagNamespace(el) { return getViewMeta(el).tagNamespace } export function isUnknownElement(el) { return !isKnownView(el) }
import { makeMap } from 'shared/util' export function isUnaryTag( el ) { return false; } export function canBeLeftOpenTag( el ) { return false; } export function mustUseProp( tag, type, name ) { return false; } export const isReservedTag = makeMap( 'template,script,style,box,group,button,colorbutton,fontbutton,text,textarea,textinput,checkbox,datepicker,timepicker,datetimepicker,progressbar,slider,radiobuttons,separator,tab,window', true ); export function getTagNamespace( tag ) { } export function isUnknownElement( tag ) { return false; } export const isBooleanAttr = makeMap( 'visible,enabled,stretchy,margined,padded,checked,horizontal,readonly' );
/* @flow */ import { makeMap } from 'shared/util' // attributes that should be using props for binding export const mustUseProp = makeMap('value,selected,checked,muted') export const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck') export const isBooleanAttr = makeMap( 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' + 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + 'required,reversed,scoped,seamless,selected,sortable,translate,' + 'truespeed,typemustmatch,visible' ) export const propsToAttrMap = { acceptCharset: 'accept-charset', className: 'class', htmlFor: 'for', httpEquiv: 'http-equiv' } export const xlinkNS = 'http://www.w3.org/1999/xlink' export const isXlink = (name: string): boolean => { return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink' }
// Regular Expressions for parsing tags and attributes const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/ // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName // but for Vue templates we can enforce a simple charset const ncname = '[a-zA-Z_][\\w\\-\\.]*' const qnameCapture = `((?:${ncname}\\:)?${ncname})` const startTagOpen = new RegExp(`^<${qnameCapture}`) const startTagClose = /^\s*(\/?)>/ const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`) const doctype = /^<!DOCTYPE [^>]+>/i // #7298: escape - to avoid being pased as HTML comment when inlined in page const comment = /^<!\--/ const conditionalComment = /^<!\[/ // Special Elements (can contain anything) export const isPlainTextElement = makeMap('script,style,textarea', true) const reCache = {} const decodingMap = { '<': '<', '>': '>', '"': '"', '&': '&', ' ': '\n', '	': '\t' } const encodedAttr = /&(?:lt|gt|quot|amp);/g const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10|#9);/g // #5992 const isIgnoreNewlineTag = makeMap('pre,textarea', true)
/* @flow */ import { makeMap } from 'shared/util' /*Github:https://github.com/answershuto*/ export const isUnaryTag = makeMap( 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + 'link,meta,param,source,track,wbr' ) // Elements that you can, intentionally, leave open // (and which close themselves) export const canBeLeftOpenTag = makeMap( 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source' ) /*Github:https://github.com/answershuto*/ // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3 // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content export const isNonPhrasingTag = makeMap( 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' + 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' + 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' + 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' + 'title,tr,track' )
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName // but for Vue templates we can enforce a simple charset const ncname = '[a-zA-Z_][\\w\\-\\.]*' const qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')' const startTagOpen = new RegExp('^<' + qnameCapture) const startTagClose = /^\s*(\/?)>/ const endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>') const doctype = /^<!DOCTYPE [^>]+>/i let IS_REGEX_CAPTURING_BROKEN = false 'x'.replace(/x(.)?/g, function (m, g) { IS_REGEX_CAPTURING_BROKEN = g === '' }) // Special Elements (can contain anything) const isSpecialTag = makeMap('script,style', true) const reCache = {} const ltRE = /</g const gtRE = />/g const nlRE = / /g const ampRE = /&/g const quoteRE = /"/g function decodeAttr (value, shouldDecodeTags, shouldDecodeNewlines) { if (shouldDecodeTags) { value = value.replace(ltRE, '<').replace(gtRE, '>') } if (shouldDecodeNewlines) { value = value.replace(nlRE, '\n')