@vue/shared 3.2.41 → 3.2.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared.cjs.js +116 -126
- package/dist/shared.cjs.prod.js +116 -126
- package/dist/shared.d.ts +1 -6
- package/dist/shared.esm-bundler.js +117 -126
- package/package.json +1 -1
package/dist/shared.cjs.js
CHANGED
|
@@ -96,127 +96,6 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
96
96
|
return res.join('\n');
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
/**
|
|
100
|
-
* On the client we only need to offer special cases for boolean attributes that
|
|
101
|
-
* have different names from their corresponding dom properties:
|
|
102
|
-
* - itemscope -> N/A
|
|
103
|
-
* - allowfullscreen -> allowFullscreen
|
|
104
|
-
* - formnovalidate -> formNoValidate
|
|
105
|
-
* - ismap -> isMap
|
|
106
|
-
* - nomodule -> noModule
|
|
107
|
-
* - novalidate -> noValidate
|
|
108
|
-
* - readonly -> readOnly
|
|
109
|
-
*/
|
|
110
|
-
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
111
|
-
const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
|
|
112
|
-
/**
|
|
113
|
-
* The full list is needed during SSR to produce the correct initial markup.
|
|
114
|
-
*/
|
|
115
|
-
const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
|
|
116
|
-
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
|
|
117
|
-
`loop,open,required,reversed,scoped,seamless,` +
|
|
118
|
-
`checked,muted,multiple,selected`);
|
|
119
|
-
/**
|
|
120
|
-
* Boolean attributes should be included if the value is truthy or ''.
|
|
121
|
-
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
122
|
-
*/
|
|
123
|
-
function includeBooleanAttr(value) {
|
|
124
|
-
return !!value || value === '';
|
|
125
|
-
}
|
|
126
|
-
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
127
|
-
const attrValidationCache = {};
|
|
128
|
-
function isSSRSafeAttrName(name) {
|
|
129
|
-
if (attrValidationCache.hasOwnProperty(name)) {
|
|
130
|
-
return attrValidationCache[name];
|
|
131
|
-
}
|
|
132
|
-
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
133
|
-
if (isUnsafe) {
|
|
134
|
-
console.error(`unsafe attribute name: ${name}`);
|
|
135
|
-
}
|
|
136
|
-
return (attrValidationCache[name] = !isUnsafe);
|
|
137
|
-
}
|
|
138
|
-
const propsToAttrMap = {
|
|
139
|
-
acceptCharset: 'accept-charset',
|
|
140
|
-
className: 'class',
|
|
141
|
-
htmlFor: 'for',
|
|
142
|
-
httpEquiv: 'http-equiv'
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* CSS properties that accept plain numbers
|
|
146
|
-
*/
|
|
147
|
-
const isNoUnitNumericStyleProp = /*#__PURE__*/ makeMap(`animation-iteration-count,border-image-outset,border-image-slice,` +
|
|
148
|
-
`border-image-width,box-flex,box-flex-group,box-ordinal-group,column-count,` +
|
|
149
|
-
`columns,flex,flex-grow,flex-positive,flex-shrink,flex-negative,flex-order,` +
|
|
150
|
-
`grid-row,grid-row-end,grid-row-span,grid-row-start,grid-column,` +
|
|
151
|
-
`grid-column-end,grid-column-span,grid-column-start,font-weight,line-clamp,` +
|
|
152
|
-
`line-height,opacity,order,orphans,tab-size,widows,z-index,zoom,` +
|
|
153
|
-
// SVG
|
|
154
|
-
`fill-opacity,flood-opacity,stop-opacity,stroke-dasharray,stroke-dashoffset,` +
|
|
155
|
-
`stroke-miterlimit,stroke-opacity,stroke-width`);
|
|
156
|
-
/**
|
|
157
|
-
* Known attributes, this is used for stringification of runtime static nodes
|
|
158
|
-
* so that we don't stringify bindings that cannot be set from HTML.
|
|
159
|
-
* Don't also forget to allow `data-*` and `aria-*`!
|
|
160
|
-
* Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
|
|
161
|
-
*/
|
|
162
|
-
const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
|
|
163
|
-
`autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
|
|
164
|
-
`border,buffered,capture,challenge,charset,checked,cite,class,code,` +
|
|
165
|
-
`codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
|
|
166
|
-
`coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
|
|
167
|
-
`disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
|
|
168
|
-
`formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
|
|
169
|
-
`height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
|
|
170
|
-
`ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
|
|
171
|
-
`manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
|
|
172
|
-
`open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
|
|
173
|
-
`referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
|
|
174
|
-
`selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
|
|
175
|
-
`start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
|
|
176
|
-
`value,width,wrap`);
|
|
177
|
-
/**
|
|
178
|
-
* Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
|
|
179
|
-
*/
|
|
180
|
-
const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
|
|
181
|
-
`arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
|
|
182
|
-
`baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
|
|
183
|
-
`clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
|
|
184
|
-
`color-interpolation-filters,color-profile,color-rendering,` +
|
|
185
|
-
`contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
|
|
186
|
-
`descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
|
|
187
|
-
`dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
|
|
188
|
-
`fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
|
|
189
|
-
`font-family,font-size,font-size-adjust,font-stretch,font-style,` +
|
|
190
|
-
`font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
|
|
191
|
-
`glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
|
|
192
|
-
`gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
|
|
193
|
-
`horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
|
|
194
|
-
`k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
|
|
195
|
-
`lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
|
|
196
|
-
`marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
|
|
197
|
-
`mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
|
|
198
|
-
`name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
|
|
199
|
-
`overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
|
|
200
|
-
`pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
|
|
201
|
-
`pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
|
|
202
|
-
`preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
|
|
203
|
-
`rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
|
|
204
|
-
`restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
|
|
205
|
-
`specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
|
|
206
|
-
`stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
|
|
207
|
-
`strikethrough-position,strikethrough-thickness,string,stroke,` +
|
|
208
|
-
`stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
|
|
209
|
-
`stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
|
|
210
|
-
`systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
|
|
211
|
-
`text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
|
|
212
|
-
`type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
|
|
213
|
-
`unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
|
|
214
|
-
`v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
|
|
215
|
-
`vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
|
|
216
|
-
`writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
|
|
217
|
-
`xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
|
|
218
|
-
`xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
|
|
219
|
-
|
|
220
99
|
function normalizeStyle(value) {
|
|
221
100
|
if (isArray(value)) {
|
|
222
101
|
const res = {};
|
|
@@ -241,10 +120,14 @@ function normalizeStyle(value) {
|
|
|
241
120
|
}
|
|
242
121
|
}
|
|
243
122
|
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
244
|
-
const propertyDelimiterRE = /:(
|
|
123
|
+
const propertyDelimiterRE = /:([^]+)/;
|
|
124
|
+
const styleCommentRE = /\/\*.*?\*\//gs;
|
|
245
125
|
function parseStringStyle(cssText) {
|
|
246
126
|
const ret = {};
|
|
247
|
-
cssText
|
|
127
|
+
cssText
|
|
128
|
+
.replace(styleCommentRE, '')
|
|
129
|
+
.split(listDelimiterRE)
|
|
130
|
+
.forEach(item => {
|
|
248
131
|
if (item) {
|
|
249
132
|
const tmp = item.split(propertyDelimiterRE);
|
|
250
133
|
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
@@ -260,8 +143,7 @@ function stringifyStyle(styles) {
|
|
|
260
143
|
for (const key in styles) {
|
|
261
144
|
const value = styles[key];
|
|
262
145
|
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
|
263
|
-
if (isString(value) ||
|
|
264
|
-
(typeof value === 'number' && isNoUnitNumericStyleProp(normalizedKey))) {
|
|
146
|
+
if (isString(value) || typeof value === 'number') {
|
|
265
147
|
// only render valid values
|
|
266
148
|
ret += `${normalizedKey}:${value};`;
|
|
267
149
|
}
|
|
@@ -342,6 +224,115 @@ const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
|
|
|
342
224
|
*/
|
|
343
225
|
const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
|
|
344
226
|
|
|
227
|
+
/**
|
|
228
|
+
* On the client we only need to offer special cases for boolean attributes that
|
|
229
|
+
* have different names from their corresponding dom properties:
|
|
230
|
+
* - itemscope -> N/A
|
|
231
|
+
* - allowfullscreen -> allowFullscreen
|
|
232
|
+
* - formnovalidate -> formNoValidate
|
|
233
|
+
* - ismap -> isMap
|
|
234
|
+
* - nomodule -> noModule
|
|
235
|
+
* - novalidate -> noValidate
|
|
236
|
+
* - readonly -> readOnly
|
|
237
|
+
*/
|
|
238
|
+
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
239
|
+
const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
|
|
240
|
+
/**
|
|
241
|
+
* The full list is needed during SSR to produce the correct initial markup.
|
|
242
|
+
*/
|
|
243
|
+
const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
|
|
244
|
+
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
|
|
245
|
+
`loop,open,required,reversed,scoped,seamless,` +
|
|
246
|
+
`checked,muted,multiple,selected`);
|
|
247
|
+
/**
|
|
248
|
+
* Boolean attributes should be included if the value is truthy or ''.
|
|
249
|
+
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
250
|
+
*/
|
|
251
|
+
function includeBooleanAttr(value) {
|
|
252
|
+
return !!value || value === '';
|
|
253
|
+
}
|
|
254
|
+
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
255
|
+
const attrValidationCache = {};
|
|
256
|
+
function isSSRSafeAttrName(name) {
|
|
257
|
+
if (attrValidationCache.hasOwnProperty(name)) {
|
|
258
|
+
return attrValidationCache[name];
|
|
259
|
+
}
|
|
260
|
+
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
261
|
+
if (isUnsafe) {
|
|
262
|
+
console.error(`unsafe attribute name: ${name}`);
|
|
263
|
+
}
|
|
264
|
+
return (attrValidationCache[name] = !isUnsafe);
|
|
265
|
+
}
|
|
266
|
+
const propsToAttrMap = {
|
|
267
|
+
acceptCharset: 'accept-charset',
|
|
268
|
+
className: 'class',
|
|
269
|
+
htmlFor: 'for',
|
|
270
|
+
httpEquiv: 'http-equiv'
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Known attributes, this is used for stringification of runtime static nodes
|
|
274
|
+
* so that we don't stringify bindings that cannot be set from HTML.
|
|
275
|
+
* Don't also forget to allow `data-*` and `aria-*`!
|
|
276
|
+
* Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
|
|
277
|
+
*/
|
|
278
|
+
const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
|
|
279
|
+
`autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
|
|
280
|
+
`border,buffered,capture,challenge,charset,checked,cite,class,code,` +
|
|
281
|
+
`codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
|
|
282
|
+
`coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
|
|
283
|
+
`disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
|
|
284
|
+
`formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
|
|
285
|
+
`height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
|
|
286
|
+
`ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
|
|
287
|
+
`manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
|
|
288
|
+
`open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
|
|
289
|
+
`referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
|
|
290
|
+
`selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
|
|
291
|
+
`start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
|
|
292
|
+
`value,width,wrap`);
|
|
293
|
+
/**
|
|
294
|
+
* Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
|
|
295
|
+
*/
|
|
296
|
+
const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
|
|
297
|
+
`arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
|
|
298
|
+
`baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
|
|
299
|
+
`clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
|
|
300
|
+
`color-interpolation-filters,color-profile,color-rendering,` +
|
|
301
|
+
`contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
|
|
302
|
+
`descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
|
|
303
|
+
`dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
|
|
304
|
+
`fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
|
|
305
|
+
`font-family,font-size,font-size-adjust,font-stretch,font-style,` +
|
|
306
|
+
`font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
|
|
307
|
+
`glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
|
|
308
|
+
`gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
|
|
309
|
+
`horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
|
|
310
|
+
`k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
|
|
311
|
+
`lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
|
|
312
|
+
`marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
|
|
313
|
+
`mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
|
|
314
|
+
`name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
|
|
315
|
+
`overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
|
|
316
|
+
`pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
|
|
317
|
+
`pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
|
|
318
|
+
`preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
|
|
319
|
+
`rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
|
|
320
|
+
`restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
|
|
321
|
+
`specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
|
|
322
|
+
`stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
|
|
323
|
+
`strikethrough-position,strikethrough-thickness,string,stroke,` +
|
|
324
|
+
`stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
|
|
325
|
+
`stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
|
|
326
|
+
`systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
|
|
327
|
+
`text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
|
|
328
|
+
`type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
|
|
329
|
+
`unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
|
|
330
|
+
`v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
|
|
331
|
+
`vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
|
|
332
|
+
`writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
|
|
333
|
+
`xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
|
|
334
|
+
`xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
|
|
335
|
+
|
|
345
336
|
const escapeRE = /["'&<>]/;
|
|
346
337
|
function escapeHtml(string) {
|
|
347
338
|
const str = '' + string;
|
|
@@ -627,7 +618,6 @@ exports.isKnownHtmlAttr = isKnownHtmlAttr;
|
|
|
627
618
|
exports.isKnownSvgAttr = isKnownSvgAttr;
|
|
628
619
|
exports.isMap = isMap;
|
|
629
620
|
exports.isModelListener = isModelListener;
|
|
630
|
-
exports.isNoUnitNumericStyleProp = isNoUnitNumericStyleProp;
|
|
631
621
|
exports.isObject = isObject;
|
|
632
622
|
exports.isOn = isOn;
|
|
633
623
|
exports.isPlainObject = isPlainObject;
|
package/dist/shared.cjs.prod.js
CHANGED
|
@@ -96,127 +96,6 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
96
96
|
return res.join('\n');
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
/**
|
|
100
|
-
* On the client we only need to offer special cases for boolean attributes that
|
|
101
|
-
* have different names from their corresponding dom properties:
|
|
102
|
-
* - itemscope -> N/A
|
|
103
|
-
* - allowfullscreen -> allowFullscreen
|
|
104
|
-
* - formnovalidate -> formNoValidate
|
|
105
|
-
* - ismap -> isMap
|
|
106
|
-
* - nomodule -> noModule
|
|
107
|
-
* - novalidate -> noValidate
|
|
108
|
-
* - readonly -> readOnly
|
|
109
|
-
*/
|
|
110
|
-
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
111
|
-
const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
|
|
112
|
-
/**
|
|
113
|
-
* The full list is needed during SSR to produce the correct initial markup.
|
|
114
|
-
*/
|
|
115
|
-
const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
|
|
116
|
-
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
|
|
117
|
-
`loop,open,required,reversed,scoped,seamless,` +
|
|
118
|
-
`checked,muted,multiple,selected`);
|
|
119
|
-
/**
|
|
120
|
-
* Boolean attributes should be included if the value is truthy or ''.
|
|
121
|
-
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
122
|
-
*/
|
|
123
|
-
function includeBooleanAttr(value) {
|
|
124
|
-
return !!value || value === '';
|
|
125
|
-
}
|
|
126
|
-
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
127
|
-
const attrValidationCache = {};
|
|
128
|
-
function isSSRSafeAttrName(name) {
|
|
129
|
-
if (attrValidationCache.hasOwnProperty(name)) {
|
|
130
|
-
return attrValidationCache[name];
|
|
131
|
-
}
|
|
132
|
-
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
133
|
-
if (isUnsafe) {
|
|
134
|
-
console.error(`unsafe attribute name: ${name}`);
|
|
135
|
-
}
|
|
136
|
-
return (attrValidationCache[name] = !isUnsafe);
|
|
137
|
-
}
|
|
138
|
-
const propsToAttrMap = {
|
|
139
|
-
acceptCharset: 'accept-charset',
|
|
140
|
-
className: 'class',
|
|
141
|
-
htmlFor: 'for',
|
|
142
|
-
httpEquiv: 'http-equiv'
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* CSS properties that accept plain numbers
|
|
146
|
-
*/
|
|
147
|
-
const isNoUnitNumericStyleProp = /*#__PURE__*/ makeMap(`animation-iteration-count,border-image-outset,border-image-slice,` +
|
|
148
|
-
`border-image-width,box-flex,box-flex-group,box-ordinal-group,column-count,` +
|
|
149
|
-
`columns,flex,flex-grow,flex-positive,flex-shrink,flex-negative,flex-order,` +
|
|
150
|
-
`grid-row,grid-row-end,grid-row-span,grid-row-start,grid-column,` +
|
|
151
|
-
`grid-column-end,grid-column-span,grid-column-start,font-weight,line-clamp,` +
|
|
152
|
-
`line-height,opacity,order,orphans,tab-size,widows,z-index,zoom,` +
|
|
153
|
-
// SVG
|
|
154
|
-
`fill-opacity,flood-opacity,stop-opacity,stroke-dasharray,stroke-dashoffset,` +
|
|
155
|
-
`stroke-miterlimit,stroke-opacity,stroke-width`);
|
|
156
|
-
/**
|
|
157
|
-
* Known attributes, this is used for stringification of runtime static nodes
|
|
158
|
-
* so that we don't stringify bindings that cannot be set from HTML.
|
|
159
|
-
* Don't also forget to allow `data-*` and `aria-*`!
|
|
160
|
-
* Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
|
|
161
|
-
*/
|
|
162
|
-
const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
|
|
163
|
-
`autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
|
|
164
|
-
`border,buffered,capture,challenge,charset,checked,cite,class,code,` +
|
|
165
|
-
`codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
|
|
166
|
-
`coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
|
|
167
|
-
`disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
|
|
168
|
-
`formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
|
|
169
|
-
`height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
|
|
170
|
-
`ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
|
|
171
|
-
`manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
|
|
172
|
-
`open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
|
|
173
|
-
`referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
|
|
174
|
-
`selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
|
|
175
|
-
`start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
|
|
176
|
-
`value,width,wrap`);
|
|
177
|
-
/**
|
|
178
|
-
* Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
|
|
179
|
-
*/
|
|
180
|
-
const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
|
|
181
|
-
`arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
|
|
182
|
-
`baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
|
|
183
|
-
`clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
|
|
184
|
-
`color-interpolation-filters,color-profile,color-rendering,` +
|
|
185
|
-
`contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
|
|
186
|
-
`descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
|
|
187
|
-
`dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
|
|
188
|
-
`fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
|
|
189
|
-
`font-family,font-size,font-size-adjust,font-stretch,font-style,` +
|
|
190
|
-
`font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
|
|
191
|
-
`glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
|
|
192
|
-
`gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
|
|
193
|
-
`horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
|
|
194
|
-
`k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
|
|
195
|
-
`lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
|
|
196
|
-
`marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
|
|
197
|
-
`mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
|
|
198
|
-
`name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
|
|
199
|
-
`overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
|
|
200
|
-
`pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
|
|
201
|
-
`pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
|
|
202
|
-
`preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
|
|
203
|
-
`rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
|
|
204
|
-
`restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
|
|
205
|
-
`specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
|
|
206
|
-
`stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
|
|
207
|
-
`strikethrough-position,strikethrough-thickness,string,stroke,` +
|
|
208
|
-
`stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
|
|
209
|
-
`stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
|
|
210
|
-
`systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
|
|
211
|
-
`text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
|
|
212
|
-
`type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
|
|
213
|
-
`unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
|
|
214
|
-
`v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
|
|
215
|
-
`vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
|
|
216
|
-
`writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
|
|
217
|
-
`xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
|
|
218
|
-
`xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
|
|
219
|
-
|
|
220
99
|
function normalizeStyle(value) {
|
|
221
100
|
if (isArray(value)) {
|
|
222
101
|
const res = {};
|
|
@@ -241,10 +120,14 @@ function normalizeStyle(value) {
|
|
|
241
120
|
}
|
|
242
121
|
}
|
|
243
122
|
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
244
|
-
const propertyDelimiterRE = /:(
|
|
123
|
+
const propertyDelimiterRE = /:([^]+)/;
|
|
124
|
+
const styleCommentRE = /\/\*.*?\*\//gs;
|
|
245
125
|
function parseStringStyle(cssText) {
|
|
246
126
|
const ret = {};
|
|
247
|
-
cssText
|
|
127
|
+
cssText
|
|
128
|
+
.replace(styleCommentRE, '')
|
|
129
|
+
.split(listDelimiterRE)
|
|
130
|
+
.forEach(item => {
|
|
248
131
|
if (item) {
|
|
249
132
|
const tmp = item.split(propertyDelimiterRE);
|
|
250
133
|
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
@@ -260,8 +143,7 @@ function stringifyStyle(styles) {
|
|
|
260
143
|
for (const key in styles) {
|
|
261
144
|
const value = styles[key];
|
|
262
145
|
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
|
263
|
-
if (isString(value) ||
|
|
264
|
-
(typeof value === 'number' && isNoUnitNumericStyleProp(normalizedKey))) {
|
|
146
|
+
if (isString(value) || typeof value === 'number') {
|
|
265
147
|
// only render valid values
|
|
266
148
|
ret += `${normalizedKey}:${value};`;
|
|
267
149
|
}
|
|
@@ -342,6 +224,115 @@ const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
|
|
|
342
224
|
*/
|
|
343
225
|
const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
|
|
344
226
|
|
|
227
|
+
/**
|
|
228
|
+
* On the client we only need to offer special cases for boolean attributes that
|
|
229
|
+
* have different names from their corresponding dom properties:
|
|
230
|
+
* - itemscope -> N/A
|
|
231
|
+
* - allowfullscreen -> allowFullscreen
|
|
232
|
+
* - formnovalidate -> formNoValidate
|
|
233
|
+
* - ismap -> isMap
|
|
234
|
+
* - nomodule -> noModule
|
|
235
|
+
* - novalidate -> noValidate
|
|
236
|
+
* - readonly -> readOnly
|
|
237
|
+
*/
|
|
238
|
+
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
239
|
+
const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
|
|
240
|
+
/**
|
|
241
|
+
* The full list is needed during SSR to produce the correct initial markup.
|
|
242
|
+
*/
|
|
243
|
+
const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
|
|
244
|
+
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
|
|
245
|
+
`loop,open,required,reversed,scoped,seamless,` +
|
|
246
|
+
`checked,muted,multiple,selected`);
|
|
247
|
+
/**
|
|
248
|
+
* Boolean attributes should be included if the value is truthy or ''.
|
|
249
|
+
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
250
|
+
*/
|
|
251
|
+
function includeBooleanAttr(value) {
|
|
252
|
+
return !!value || value === '';
|
|
253
|
+
}
|
|
254
|
+
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
255
|
+
const attrValidationCache = {};
|
|
256
|
+
function isSSRSafeAttrName(name) {
|
|
257
|
+
if (attrValidationCache.hasOwnProperty(name)) {
|
|
258
|
+
return attrValidationCache[name];
|
|
259
|
+
}
|
|
260
|
+
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
261
|
+
if (isUnsafe) {
|
|
262
|
+
console.error(`unsafe attribute name: ${name}`);
|
|
263
|
+
}
|
|
264
|
+
return (attrValidationCache[name] = !isUnsafe);
|
|
265
|
+
}
|
|
266
|
+
const propsToAttrMap = {
|
|
267
|
+
acceptCharset: 'accept-charset',
|
|
268
|
+
className: 'class',
|
|
269
|
+
htmlFor: 'for',
|
|
270
|
+
httpEquiv: 'http-equiv'
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Known attributes, this is used for stringification of runtime static nodes
|
|
274
|
+
* so that we don't stringify bindings that cannot be set from HTML.
|
|
275
|
+
* Don't also forget to allow `data-*` and `aria-*`!
|
|
276
|
+
* Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
|
|
277
|
+
*/
|
|
278
|
+
const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
|
|
279
|
+
`autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
|
|
280
|
+
`border,buffered,capture,challenge,charset,checked,cite,class,code,` +
|
|
281
|
+
`codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
|
|
282
|
+
`coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
|
|
283
|
+
`disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
|
|
284
|
+
`formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
|
|
285
|
+
`height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
|
|
286
|
+
`ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
|
|
287
|
+
`manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
|
|
288
|
+
`open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
|
|
289
|
+
`referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
|
|
290
|
+
`selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
|
|
291
|
+
`start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
|
|
292
|
+
`value,width,wrap`);
|
|
293
|
+
/**
|
|
294
|
+
* Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
|
|
295
|
+
*/
|
|
296
|
+
const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
|
|
297
|
+
`arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
|
|
298
|
+
`baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
|
|
299
|
+
`clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
|
|
300
|
+
`color-interpolation-filters,color-profile,color-rendering,` +
|
|
301
|
+
`contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
|
|
302
|
+
`descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
|
|
303
|
+
`dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
|
|
304
|
+
`fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
|
|
305
|
+
`font-family,font-size,font-size-adjust,font-stretch,font-style,` +
|
|
306
|
+
`font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
|
|
307
|
+
`glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
|
|
308
|
+
`gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
|
|
309
|
+
`horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
|
|
310
|
+
`k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
|
|
311
|
+
`lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
|
|
312
|
+
`marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
|
|
313
|
+
`mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
|
|
314
|
+
`name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
|
|
315
|
+
`overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
|
|
316
|
+
`pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
|
|
317
|
+
`pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
|
|
318
|
+
`preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
|
|
319
|
+
`rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
|
|
320
|
+
`restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
|
|
321
|
+
`specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
|
|
322
|
+
`stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
|
|
323
|
+
`strikethrough-position,strikethrough-thickness,string,stroke,` +
|
|
324
|
+
`stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
|
|
325
|
+
`stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
|
|
326
|
+
`systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
|
|
327
|
+
`text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
|
|
328
|
+
`type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
|
|
329
|
+
`unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
|
|
330
|
+
`v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
|
|
331
|
+
`vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
|
|
332
|
+
`writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
|
|
333
|
+
`xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
|
|
334
|
+
`xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
|
|
335
|
+
|
|
345
336
|
const escapeRE = /["'&<>]/;
|
|
346
337
|
function escapeHtml(string) {
|
|
347
338
|
const str = '' + string;
|
|
@@ -626,7 +617,6 @@ exports.isKnownHtmlAttr = isKnownHtmlAttr;
|
|
|
626
617
|
exports.isKnownSvgAttr = isKnownSvgAttr;
|
|
627
618
|
exports.isMap = isMap;
|
|
628
619
|
exports.isModelListener = isModelListener;
|
|
629
|
-
exports.isNoUnitNumericStyleProp = isNoUnitNumericStyleProp;
|
|
630
620
|
exports.isObject = isObject;
|
|
631
621
|
exports.isOn = isOn;
|
|
632
622
|
exports.isPlainObject = isPlainObject;
|
package/dist/shared.d.ts
CHANGED
|
@@ -92,11 +92,6 @@ export declare const isMap: (val: unknown) => val is Map<any, any>;
|
|
|
92
92
|
|
|
93
93
|
export declare const isModelListener: (key: string) => boolean;
|
|
94
94
|
|
|
95
|
-
/**
|
|
96
|
-
* CSS properties that accept plain numbers
|
|
97
|
-
*/
|
|
98
|
-
export declare const isNoUnitNumericStyleProp: (key: string) => boolean;
|
|
99
|
-
|
|
100
95
|
export declare const isObject: (val: unknown) => val is Record<any, any>;
|
|
101
96
|
|
|
102
97
|
export declare const isOn: (key: string) => boolean;
|
|
@@ -134,7 +129,7 @@ export declare function looseEqual(a: any, b: any): boolean;
|
|
|
134
129
|
export declare function looseIndexOf(arr: any[], val: any): number;
|
|
135
130
|
|
|
136
131
|
export declare type LooseRequired<T> = {
|
|
137
|
-
[P in
|
|
132
|
+
[P in keyof (T & Required<T>)]: T[P];
|
|
138
133
|
};
|
|
139
134
|
|
|
140
135
|
/**
|
|
@@ -92,127 +92,6 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
92
92
|
return res.join('\n');
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
/**
|
|
96
|
-
* On the client we only need to offer special cases for boolean attributes that
|
|
97
|
-
* have different names from their corresponding dom properties:
|
|
98
|
-
* - itemscope -> N/A
|
|
99
|
-
* - allowfullscreen -> allowFullscreen
|
|
100
|
-
* - formnovalidate -> formNoValidate
|
|
101
|
-
* - ismap -> isMap
|
|
102
|
-
* - nomodule -> noModule
|
|
103
|
-
* - novalidate -> noValidate
|
|
104
|
-
* - readonly -> readOnly
|
|
105
|
-
*/
|
|
106
|
-
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
107
|
-
const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
|
|
108
|
-
/**
|
|
109
|
-
* The full list is needed during SSR to produce the correct initial markup.
|
|
110
|
-
*/
|
|
111
|
-
const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
|
|
112
|
-
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
|
|
113
|
-
`loop,open,required,reversed,scoped,seamless,` +
|
|
114
|
-
`checked,muted,multiple,selected`);
|
|
115
|
-
/**
|
|
116
|
-
* Boolean attributes should be included if the value is truthy or ''.
|
|
117
|
-
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
118
|
-
*/
|
|
119
|
-
function includeBooleanAttr(value) {
|
|
120
|
-
return !!value || value === '';
|
|
121
|
-
}
|
|
122
|
-
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
123
|
-
const attrValidationCache = {};
|
|
124
|
-
function isSSRSafeAttrName(name) {
|
|
125
|
-
if (attrValidationCache.hasOwnProperty(name)) {
|
|
126
|
-
return attrValidationCache[name];
|
|
127
|
-
}
|
|
128
|
-
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
129
|
-
if (isUnsafe) {
|
|
130
|
-
console.error(`unsafe attribute name: ${name}`);
|
|
131
|
-
}
|
|
132
|
-
return (attrValidationCache[name] = !isUnsafe);
|
|
133
|
-
}
|
|
134
|
-
const propsToAttrMap = {
|
|
135
|
-
acceptCharset: 'accept-charset',
|
|
136
|
-
className: 'class',
|
|
137
|
-
htmlFor: 'for',
|
|
138
|
-
httpEquiv: 'http-equiv'
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* CSS properties that accept plain numbers
|
|
142
|
-
*/
|
|
143
|
-
const isNoUnitNumericStyleProp = /*#__PURE__*/ makeMap(`animation-iteration-count,border-image-outset,border-image-slice,` +
|
|
144
|
-
`border-image-width,box-flex,box-flex-group,box-ordinal-group,column-count,` +
|
|
145
|
-
`columns,flex,flex-grow,flex-positive,flex-shrink,flex-negative,flex-order,` +
|
|
146
|
-
`grid-row,grid-row-end,grid-row-span,grid-row-start,grid-column,` +
|
|
147
|
-
`grid-column-end,grid-column-span,grid-column-start,font-weight,line-clamp,` +
|
|
148
|
-
`line-height,opacity,order,orphans,tab-size,widows,z-index,zoom,` +
|
|
149
|
-
// SVG
|
|
150
|
-
`fill-opacity,flood-opacity,stop-opacity,stroke-dasharray,stroke-dashoffset,` +
|
|
151
|
-
`stroke-miterlimit,stroke-opacity,stroke-width`);
|
|
152
|
-
/**
|
|
153
|
-
* Known attributes, this is used for stringification of runtime static nodes
|
|
154
|
-
* so that we don't stringify bindings that cannot be set from HTML.
|
|
155
|
-
* Don't also forget to allow `data-*` and `aria-*`!
|
|
156
|
-
* Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
|
|
157
|
-
*/
|
|
158
|
-
const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
|
|
159
|
-
`autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
|
|
160
|
-
`border,buffered,capture,challenge,charset,checked,cite,class,code,` +
|
|
161
|
-
`codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
|
|
162
|
-
`coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
|
|
163
|
-
`disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
|
|
164
|
-
`formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
|
|
165
|
-
`height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
|
|
166
|
-
`ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
|
|
167
|
-
`manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
|
|
168
|
-
`open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
|
|
169
|
-
`referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
|
|
170
|
-
`selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
|
|
171
|
-
`start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
|
|
172
|
-
`value,width,wrap`);
|
|
173
|
-
/**
|
|
174
|
-
* Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
|
|
175
|
-
*/
|
|
176
|
-
const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
|
|
177
|
-
`arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
|
|
178
|
-
`baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
|
|
179
|
-
`clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
|
|
180
|
-
`color-interpolation-filters,color-profile,color-rendering,` +
|
|
181
|
-
`contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
|
|
182
|
-
`descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
|
|
183
|
-
`dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
|
|
184
|
-
`fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
|
|
185
|
-
`font-family,font-size,font-size-adjust,font-stretch,font-style,` +
|
|
186
|
-
`font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
|
|
187
|
-
`glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
|
|
188
|
-
`gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
|
|
189
|
-
`horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
|
|
190
|
-
`k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
|
|
191
|
-
`lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
|
|
192
|
-
`marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
|
|
193
|
-
`mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
|
|
194
|
-
`name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
|
|
195
|
-
`overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
|
|
196
|
-
`pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
|
|
197
|
-
`pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
|
|
198
|
-
`preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
|
|
199
|
-
`rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
|
|
200
|
-
`restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
|
|
201
|
-
`specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
|
|
202
|
-
`stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
|
|
203
|
-
`strikethrough-position,strikethrough-thickness,string,stroke,` +
|
|
204
|
-
`stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
|
|
205
|
-
`stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
|
|
206
|
-
`systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
|
|
207
|
-
`text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
|
|
208
|
-
`type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
|
|
209
|
-
`unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
|
|
210
|
-
`v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
|
|
211
|
-
`vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
|
|
212
|
-
`writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
|
|
213
|
-
`xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
|
|
214
|
-
`xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
|
|
215
|
-
|
|
216
95
|
function normalizeStyle(value) {
|
|
217
96
|
if (isArray(value)) {
|
|
218
97
|
const res = {};
|
|
@@ -237,10 +116,14 @@ function normalizeStyle(value) {
|
|
|
237
116
|
}
|
|
238
117
|
}
|
|
239
118
|
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
240
|
-
const propertyDelimiterRE = /:(
|
|
119
|
+
const propertyDelimiterRE = /:([^]+)/;
|
|
120
|
+
const styleCommentRE = /\/\*.*?\*\//gs;
|
|
241
121
|
function parseStringStyle(cssText) {
|
|
242
122
|
const ret = {};
|
|
243
|
-
cssText
|
|
123
|
+
cssText
|
|
124
|
+
.replace(styleCommentRE, '')
|
|
125
|
+
.split(listDelimiterRE)
|
|
126
|
+
.forEach(item => {
|
|
244
127
|
if (item) {
|
|
245
128
|
const tmp = item.split(propertyDelimiterRE);
|
|
246
129
|
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
@@ -256,8 +139,7 @@ function stringifyStyle(styles) {
|
|
|
256
139
|
for (const key in styles) {
|
|
257
140
|
const value = styles[key];
|
|
258
141
|
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
|
259
|
-
if (isString(value) ||
|
|
260
|
-
(typeof value === 'number' && isNoUnitNumericStyleProp(normalizedKey))) {
|
|
142
|
+
if (isString(value) || typeof value === 'number') {
|
|
261
143
|
// only render valid values
|
|
262
144
|
ret += `${normalizedKey}:${value};`;
|
|
263
145
|
}
|
|
@@ -338,6 +220,115 @@ const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
|
|
|
338
220
|
*/
|
|
339
221
|
const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
|
|
340
222
|
|
|
223
|
+
/**
|
|
224
|
+
* On the client we only need to offer special cases for boolean attributes that
|
|
225
|
+
* have different names from their corresponding dom properties:
|
|
226
|
+
* - itemscope -> N/A
|
|
227
|
+
* - allowfullscreen -> allowFullscreen
|
|
228
|
+
* - formnovalidate -> formNoValidate
|
|
229
|
+
* - ismap -> isMap
|
|
230
|
+
* - nomodule -> noModule
|
|
231
|
+
* - novalidate -> noValidate
|
|
232
|
+
* - readonly -> readOnly
|
|
233
|
+
*/
|
|
234
|
+
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
235
|
+
const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
|
|
236
|
+
/**
|
|
237
|
+
* The full list is needed during SSR to produce the correct initial markup.
|
|
238
|
+
*/
|
|
239
|
+
const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
|
|
240
|
+
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
|
|
241
|
+
`loop,open,required,reversed,scoped,seamless,` +
|
|
242
|
+
`checked,muted,multiple,selected`);
|
|
243
|
+
/**
|
|
244
|
+
* Boolean attributes should be included if the value is truthy or ''.
|
|
245
|
+
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
246
|
+
*/
|
|
247
|
+
function includeBooleanAttr(value) {
|
|
248
|
+
return !!value || value === '';
|
|
249
|
+
}
|
|
250
|
+
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
251
|
+
const attrValidationCache = {};
|
|
252
|
+
function isSSRSafeAttrName(name) {
|
|
253
|
+
if (attrValidationCache.hasOwnProperty(name)) {
|
|
254
|
+
return attrValidationCache[name];
|
|
255
|
+
}
|
|
256
|
+
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
257
|
+
if (isUnsafe) {
|
|
258
|
+
console.error(`unsafe attribute name: ${name}`);
|
|
259
|
+
}
|
|
260
|
+
return (attrValidationCache[name] = !isUnsafe);
|
|
261
|
+
}
|
|
262
|
+
const propsToAttrMap = {
|
|
263
|
+
acceptCharset: 'accept-charset',
|
|
264
|
+
className: 'class',
|
|
265
|
+
htmlFor: 'for',
|
|
266
|
+
httpEquiv: 'http-equiv'
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Known attributes, this is used for stringification of runtime static nodes
|
|
270
|
+
* so that we don't stringify bindings that cannot be set from HTML.
|
|
271
|
+
* Don't also forget to allow `data-*` and `aria-*`!
|
|
272
|
+
* Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
|
|
273
|
+
*/
|
|
274
|
+
const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
|
|
275
|
+
`autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
|
|
276
|
+
`border,buffered,capture,challenge,charset,checked,cite,class,code,` +
|
|
277
|
+
`codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
|
|
278
|
+
`coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
|
|
279
|
+
`disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
|
|
280
|
+
`formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
|
|
281
|
+
`height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
|
|
282
|
+
`ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
|
|
283
|
+
`manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
|
|
284
|
+
`open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
|
|
285
|
+
`referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
|
|
286
|
+
`selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
|
|
287
|
+
`start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
|
|
288
|
+
`value,width,wrap`);
|
|
289
|
+
/**
|
|
290
|
+
* Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
|
|
291
|
+
*/
|
|
292
|
+
const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
|
|
293
|
+
`arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
|
|
294
|
+
`baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
|
|
295
|
+
`clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
|
|
296
|
+
`color-interpolation-filters,color-profile,color-rendering,` +
|
|
297
|
+
`contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
|
|
298
|
+
`descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
|
|
299
|
+
`dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
|
|
300
|
+
`fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
|
|
301
|
+
`font-family,font-size,font-size-adjust,font-stretch,font-style,` +
|
|
302
|
+
`font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
|
|
303
|
+
`glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
|
|
304
|
+
`gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
|
|
305
|
+
`horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
|
|
306
|
+
`k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
|
|
307
|
+
`lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
|
|
308
|
+
`marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
|
|
309
|
+
`mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
|
|
310
|
+
`name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
|
|
311
|
+
`overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
|
|
312
|
+
`pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
|
|
313
|
+
`pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
|
|
314
|
+
`preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
|
|
315
|
+
`rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
|
|
316
|
+
`restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
|
|
317
|
+
`specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
|
|
318
|
+
`stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
|
|
319
|
+
`strikethrough-position,strikethrough-thickness,string,stroke,` +
|
|
320
|
+
`stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
|
|
321
|
+
`stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
|
|
322
|
+
`systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
|
|
323
|
+
`text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
|
|
324
|
+
`type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
|
|
325
|
+
`unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
|
|
326
|
+
`v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
|
|
327
|
+
`vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
|
|
328
|
+
`writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
|
|
329
|
+
`xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
|
|
330
|
+
`xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
|
|
331
|
+
|
|
341
332
|
const escapeRE = /["'&<>]/;
|
|
342
333
|
function escapeHtml(string) {
|
|
343
334
|
const str = '' + string;
|
|
@@ -593,4 +584,4 @@ function genPropsAccessExp(name) {
|
|
|
593
584
|
: `__props[${JSON.stringify(name)}]`;
|
|
594
585
|
}
|
|
595
586
|
|
|
596
|
-
export { EMPTY_ARR, EMPTY_OBJ, NO, NOOP, PatchFlagNames, camelize, capitalize, def, escapeHtml, escapeHtmlComment, extend, genPropsAccessExp, generateCodeFrame, getGlobalThis, hasChanged, hasOwn, hyphenate, includeBooleanAttr, invokeArrayFns, isArray, isBooleanAttr, isBuiltInDirective, isDate, isFunction, isGloballyWhitelisted, isHTMLTag, isIntegerKey, isKnownHtmlAttr, isKnownSvgAttr, isMap, isModelListener,
|
|
587
|
+
export { EMPTY_ARR, EMPTY_OBJ, NO, NOOP, PatchFlagNames, camelize, capitalize, def, escapeHtml, escapeHtmlComment, extend, genPropsAccessExp, generateCodeFrame, getGlobalThis, hasChanged, hasOwn, hyphenate, includeBooleanAttr, invokeArrayFns, isArray, isBooleanAttr, isBuiltInDirective, isDate, isFunction, isGloballyWhitelisted, isHTMLTag, isIntegerKey, isKnownHtmlAttr, isKnownSvgAttr, isMap, isModelListener, isObject, isOn, isPlainObject, isPromise, isReservedProp, isSSRSafeAttrName, isSVGTag, isSet, isSpecialBooleanAttr, isString, isSymbol, isVoidTag, looseEqual, looseIndexOf, makeMap, normalizeClass, normalizeProps, normalizeStyle, objectToString, parseStringStyle, propsToAttrMap, remove, slotFlagsText, stringifyStyle, toDisplayString, toHandlerKey, toNumber, toRawType, toTypeString };
|