Skip to content

Commit

Permalink
refactor: simplify array handling (#5734)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Nov 18, 2021
1 parent dcaaa0f commit 2cacc6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 1 addition & 5 deletions packages/plugin-vue/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,7 @@ export function resolveTemplateCompilerOptions(

if (transformAssetUrls && typeof transformAssetUrls === 'object') {
// presence of array fields means this is raw tags config
if (
Object.keys(transformAssetUrls).some((key) =>
Array.isArray((transformAssetUrls as any)[key])
)
) {
if (Object.values(transformAssetUrls).some((val) => Array.isArray(val))) {
transformAssetUrls = {
...assetUrlOptions,
tags: transformAssetUrls as any
Expand Down
6 changes: 2 additions & 4 deletions packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ async function handleMessage(payload: HMRPayload) {
// can't use querySelector with `[href*=]` here since the link may be
// using relative paths so we need to use link.href to grab the full
// URL for the include check.
const el = (
[].slice.call(
document.querySelectorAll(`link`)
) as HTMLLinkElement[]
const el = Array.from(
document.querySelectorAll<HTMLLinkElement>('link')
).find((e) => e.href.includes(path))
if (el) {
const newPath = `${base}${path.slice(1)}${
Expand Down

0 comments on commit 2cacc6b

Please sign in to comment.