Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

astro-vtbot

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-vtbot - npm Package Compare versions

Comparing version 1.7.13 to 1.7.14

30

components/swap-utils.ts

@@ -0,1 +1,3 @@

const PERSIST_ATTR = 'data-astro-transition-persist';
type SavedFocus = {

@@ -39,4 +41,7 @@ activeElement: HTMLElement | null;

[...document.head.children].forEach((e) => {
if (e instanceof HTMLElement) {
let other = [...doc.head.children].find((o) => o.isEqualNode(e));
const id = e.getAttribute(PERSIST_ATTR);
let other: Element | "" | null | undefined = id && doc.head.querySelector(`[${PERSIST_ATTR}="${id}"]`);
other ||= [...doc.head.children].find((o) => o.isEqualNode(e));
(other ?? e).remove();

@@ -77,2 +82,25 @@ }

export function astroBodySwap(oldEl: Element, newEl: Element) {
const PERSIST_ATTR = 'data-astro-transition-persist';
const shouldCopyProps = (el: HTMLElement) => {
const persistProps = el.dataset.astroTransitionPersistProps;
return persistProps == null || persistProps === 'false';
};
oldEl.replaceWith(newEl);
for (const el of oldEl.querySelectorAll(`[${PERSIST_ATTR}]`)) {
const id = el.getAttribute(PERSIST_ATTR);
const newEl = document.querySelector(`[${PERSIST_ATTR}="${id}"]`);
if (newEl) {
newEl.replaceWith(el);
if (el.localName === 'astro-island' && shouldCopyProps(el as HTMLElement)) {
el.setAttribute('ssr', '');
el.setAttribute('props', newEl.getAttribute('props')!);
}
}
}
}
/*

@@ -79,0 +107,0 @@ * Execute all steps of the original swap function except the swap of the body element.

2

package.json

@@ -6,3 +6,3 @@ {

},
"version": "1.7.13",
"version": "1.7.14",
"description": "The 👜 Bag of Tricks ✨ for Astro's View Transitions",

@@ -9,0 +9,0 @@ "homepage": "https://github.com/martrapp/astro-vtbot#readme",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc