From d0d0a38598c9436a786c1f88aec23e305a09fa7f Mon Sep 17 00:00:00 2001 From: mertsincan Date: Sat, 30 Mar 2024 23:49:34 +0000 Subject: [PATCH] Add onLoad option to useStyle --- components/lib/tooltip/style/TooltipStyle.js | 2 +- components/lib/usestyle/UseStyle.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/lib/tooltip/style/TooltipStyle.js b/components/lib/tooltip/style/TooltipStyle.js index e09e00e1a..1ad125abe 100644 --- a/components/lib/tooltip/style/TooltipStyle.js +++ b/components/lib/tooltip/style/TooltipStyle.js @@ -7,6 +7,6 @@ const classes = { }; export default BaseStyle.extend({ - name: 'tooltip', + name: 'tooltip-directive', classes }); diff --git a/components/lib/usestyle/UseStyle.js b/components/lib/usestyle/UseStyle.js index 4cd6d74fe..625a0ae7d 100644 --- a/components/lib/usestyle/UseStyle.js +++ b/components/lib/usestyle/UseStyle.js @@ -19,7 +19,7 @@ export function useStyle(css, options = {}) { const styleRef = ref(null); const defaultDocument = DomHandler.isClient() ? window.document : undefined; - const { document = defaultDocument, immediate = true, manual = false, name = `style_${++_id}`, id = undefined, media = undefined, nonce = undefined, first = false, props = {} } = options; + const { document = defaultDocument, immediate = true, manual = false, name = `style_${++_id}`, id = undefined, media = undefined, nonce = undefined, first = false, onLoad = undefined, props = {} } = options; let stop = () => {}; @@ -44,6 +44,7 @@ export function useStyle(css, options = {}) { first ? document.head.prepend(styleRef.value) : document.head.appendChild(styleRef.value); DomHandler.setAttribute(styleRef.value, 'data-primevue-style-id', name); DomHandler.setAttributes(styleRef.value, _styleProps); + styleRef.value.onload = onLoad; } if (isLoaded.value) return; @@ -74,6 +75,7 @@ export function useStyle(css, options = {}) { return { id, name, + el: styleRef, css: cssRef, unload, load,