Skip to content

Commit

Permalink
Renamed nextTick to queueFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryjappinen committed Jun 23, 2024
1 parent 805e641 commit 9dfc6a6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
6 changes: 3 additions & 3 deletions components/Bodytext.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import eventHasAnyMetaKey from '../utils/eventHasAnyMetaKey'
import linkIsInternal from '../utils/linkIsInternal'
import nextTick from '../utils/nextTick'
import queueFrame from '../utils/queueFrame'
defineProps({
Expand All @@ -17,7 +17,7 @@ defineProps({
})
// FIXME: replication
// FIXME: duplication
// FIXME: should be in a utility
const modifyExternalLink = (el) => {
const originalRel = el.getAttribute('rel')
Expand All @@ -34,7 +34,7 @@ const modifyExternalLink = (el) => {
}
// Return previous attributes after a delay
nextTick(() => {
queueFrame(() => {
if (originalRel !== desiredRel) {
if (originalRel) {
el.setAttribute('rel', originalRel)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bonn",
"version": "0.10.1",
"version": "0.10.2",
"description": "Utility, style and component library for web development.",
"private": false,
"files": [
Expand Down
34 changes: 34 additions & 0 deletions spec/utils/queueFrame.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { describe, it, expect } from 'vitest'

import queueFrame from '../../utils/queueFrame'
import wait from '../../utils/wait'

describe.concurrent('queueFrame', () => {
it('should run asynchronously', async () => {
let a = false

queueFrame(() => {
a = true
})

expect(a).toEqual(false)

await wait(5)

expect(a).toEqual(true)
})

it('can be canceled', async () => {
let a = false

const cancel = queueFrame(() => {
a = true
})

cancel()

await wait(5)

expect(a).toEqual(false)
})
})
2 changes: 1 addition & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export { default as linkIsInternal } from './utils/linkIsInternal'
export { default as md5 } from './utils/md5'
export { default as mergeConfigs } from './utils/mergeConfigs'
export { default as mergeWithArrays } from './utils/mergeWithArrays'
export { default as nextTick } from './utils/nextTick'
export { default as normalizeDate } from './utils/normalizeDate'
export { default as now } from './utils/now'
export { default as nowEpoch } from './utils/nowEpoch'
Expand All @@ -101,6 +100,7 @@ export { default as removePrefix } from './utils/removePrefix'
export { default as removeSuffix } from './utils/removeSuffix'
export { default as removeTrailingSlash } from './utils/removeTrailingSlash'
export { default as replaceAll } from './utils/replaceAll'
export { default as queueFrame } from './utils/queueFrame'
export { default as sendEmail } from './utils/sendEmail'
export { default as suffixWith } from './utils/suffixWith'
export { default as toDecimal } from './utils/toDecimal'
Expand Down
File renamed without changes.

0 comments on commit 9dfc6a6

Please sign in to comment.