1.2.8 • Published 1 day ago

@frankhoodbs/w3c-v-cloak-patch v1.2.8

Weekly downloads
-
License
ISC
Repository
-
Last release
1 day ago

VCloak Patch Utility

A simple utility to manage Vue's v-cloak directive attribute for an element in the DOM while ensuring HTML validity according to W3C standards.

Description

Vue uses the v-cloak directive to keep an element and its children hidden until its compilation is done. Once compiled, Vue removes the v-cloak attribute, making the element visible.

However, according to W3C standards, custom attributes without the data- prefix are not considered valid in HTML. This is where this utility comes into play.

applyVCloakPatch swaps the non-standard v-cloak with a data-v-cloak attribute to ensure your HTML remains valid according to W3C standards. This utility is useful in scenarios where maintaining a standard-compliant markup is essential while still benefiting from Vue's v-cloak directive.

Usage

  1. Import the utility:
import applyVCloakPatch from '@frankhoodbs/w3c-v-cloak-patch';
  1. Utilize the utility:
// Apply the patch to an element by providing its node ID.
applyVCloakPatch('myNodeId');

For example, for the HTML element:

<div id="myApp" data-v-cloak>
  ...
</div>

By calling applyVCloakPatch('myApp'), the element will transform into:

<div id="myApp" v-cloak>
  ...
</div>

API Reference

applyVCloakPatch(nodeId: string)

  • nodeId (string): The ID of the DOM element to apply the patch.

Upon invocation, this function searches for the element with the provided ID. If the element has the data-v-cloak attribute, it removes it and sets the non-standard v-cloak attribute.

1.2.8

1 day ago

1.2.7

1 day ago

1.2.4

2 days ago

1.2.3

6 days ago

1.2.2

19 days ago

1.2.1

22 days ago

1.2.0

23 days ago

1.1.16

23 days ago

1.1.15

2 months ago

1.1.14

2 months ago

1.1.13

2 months ago

1.1.12

2 months ago

1.1.11

3 months ago

1.1.10

3 months ago

1.1.9

4 months ago

1.1.8

4 months ago

1.1.7

4 months ago

1.1.6

4 months ago

1.1.5

4 months ago

1.1.1

4 months ago

1.1.2

4 months ago

1.0.12

7 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.0

10 months ago