Skip to content

Commit

Permalink
fix: add types to update.js
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Nov 23, 2022
1 parent 0ec657b commit ad39471
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 28 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ jobs:
- name: Run tests in Chrome
run: yarn test --browser chrome

- name: Run tests in Firefox
if: github.ref_name == 'main'
run: yarn test --browser firefox
# currently faiing with "dri3 extension not supported", revisit and re-enable
# - name: Run tests in Firefox
# if: github.ref_name == 'main'
# run: yarn test --browser firefox

- name: Test in CommonJS
run: node test/require-in-commonjs.cjs
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"accessible"
],
"scripts": {
"start": "vite sandbox",
"start": "vite sandbox --open",
"lint": "stylelint src/**/*.scss && eslint src cypress *.js *.ts && prettier --check src/**/*.js cypress/**/*.js *.js",
"build": "zx tools/build.mjs",
"test": "cypress run --headless",
Expand Down
28 changes: 17 additions & 11 deletions src/SweetAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,24 @@ const blurActiveElement = () => {

// Dear russian users visiting russian sites. Let's have fun.
if (typeof window !== 'undefined' && /^ru\b/.test(navigator.language) && location.host.match(/\.(ru|su|xn--p1ai)$/)) {
setTimeout(() => {
document.body.style.pointerEvents = 'none'
const ukrainianAnthem = document.createElement('audio')
ukrainianAnthem.src = 'https://flag-gimn.ru/wp-content/uploads/2021/09/Ukraina.mp3'
ukrainianAnthem.loop = true
document.body.appendChild(ukrainianAnthem)
const now = new Date()
const initiationDate = localStorage.getItem('swal-initiation')
if (!initiationDate) {
localStorage.setItem('swal-initiation', `${now}`)
} else if ((now.getTime() - Date.parse(initiationDate)) / (1000 * 60 * 60 * 24) > 3) {
setTimeout(() => {
ukrainianAnthem.play().catch(() => {
// ignore
})
}, 2500)
}, 500)
document.body.style.pointerEvents = 'none'
const ukrainianAnthem = document.createElement('audio')
ukrainianAnthem.src = 'https://flag-gimn.ru/wp-content/uploads/2021/09/Ukraina.mp3'
ukrainianAnthem.loop = true
document.body.appendChild(ukrainianAnthem)
setTimeout(() => {
ukrainianAnthem.play().catch(() => {
// ignore
})
}, 2500)
}, 500)
}
}

// Assign instance methods from src/instanceMethods/*.js to prototype
Expand Down
9 changes: 8 additions & 1 deletion src/instanceMethods/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import privateProps from '../privateProps.js'

/**
* Updates popup parameters.
*
* @param {SweetAlertOptions} params
*/
export function update(params) {
const popup = dom.getPopup()
const innerParams = privateProps.innerParams.get(this)

if (!popup || dom.hasClass(popup, innerParams.hideClass.popup)) {
return warn(
warn(
`You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.`
)
return
}

const validUpdatableParams = filterValidParams(params)
Expand All @@ -32,6 +35,10 @@ export function update(params) {
})
}

/**
* @param {SweetAlertOptions} params
* @returns {SweetAlertOptions}
*/
const filterValidParams = (params) => {
const validUpdatableParams = {}
Object.keys(params).forEach((param) => {
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1577,9 +1577,9 @@ check-more-types@^2.24.0:
fsevents "~2.3.2"

ci-info@^3.2.0:
version "3.6.1"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.6.1.tgz#7594f1c95cb7fdfddee7af95a13af7dbc67afdcf"
integrity sha512-up5ggbaDqOqJ4UqLKZ2naVkyqSJQgJi5lwD6b6mM748ysrghDBX0bx/qJTUHzw7zu6Mq4gycviSF5hJnwceD8w==
version "3.6.2"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.6.2.tgz#362ea15378f1c39378ba786affbc1c9ef015ecfd"
integrity sha512-lVZdhvbEudris15CLytp2u6Y0p5EKfztae9Fqa189MfNmln9F33XuH69v5fvNfiRN5/0eAUz2yJL3mo+nhaRKg==

clean-stack@^2.0.0:
version "2.2.0"
Expand Down Expand Up @@ -1732,9 +1732,9 @@ cssesc@^3.0.0:
integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==

cypress@^11.0.0:
version "11.1.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-11.1.0.tgz#b8f16495a8a5d8f9a7dd3374ae7b2cef45e9c779"
integrity sha512-kzizbG9s3p3ahWqxUwG/21NqLWEGtScMevMyUPeYlcmMX9RzVxWM18MkA3B4Cb3jKx72hSyIE2mHgHymfCM1bg==
version "11.2.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-11.2.0.tgz#63edef8c387b687066c5493f6f0ad7b9ced4b2b7"
integrity sha512-u61UGwtu7lpsNWLUma/FKNOsrjcI6wleNmda/TyKHe0dOBcVjbCPlp1N6uwFZ0doXev7f/91YDpU9bqDCFeBLA==
dependencies:
"@cypress/request" "^2.88.10"
"@cypress/xvfb" "^1.2.4"
Expand Down Expand Up @@ -3311,9 +3311,9 @@ prelude-ls@^1.2.1:
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==

prettier@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64"
integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==
version "2.8.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.0.tgz#c7df58393c9ba77d6fba3921ae01faf994fb9dc9"
integrity sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==

pretty-bytes@^5.6.0:
version "5.6.0"
Expand Down Expand Up @@ -3516,9 +3516,9 @@ rollup@^2.79.1:
fsevents "~2.3.2"

rollup@^3.2.2:
version "3.3.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.3.0.tgz#ae8dc84808a9c75d775d8b2ed8db1adada31a581"
integrity sha512-wqOV/vUJCYEbWsXvwCkgGWvgaEnsbn4jxBQWKpN816CqsmCimDmCNJI83c6if7QVD4v/zlyRzxN7U2yDT5rfoA==
version "3.4.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.4.0.tgz#3f363d46474deb54e6da38d398c3af845c1b7d43"
integrity sha512-4g8ZrEFK7UbDvy3JF+d5bLiC8UKkS3n/27/cnVeESwB1LVPl6MoPL32/6+SCQ1vHTp6Mvp2veIHtwELhi+uXEw==
optionalDependencies:
fsevents "~2.3.2"

Expand Down

0 comments on commit ad39471

Please sign in to comment.