Skip to content

iAPI: Deprecate data-wp-ignore #70881

Closed

Description

@DAreRodz

What problem does this address?

The data-wp-ignore directive is designed to prevent hydrating a specific part of an interactive region. However, the current implementation breaks context inheritance and could cause issues with client-side navigation. Supporting these cases would be complex.

Moreover, it doesn't cover a real use case at this moment, so the best option would be to just remove this directive.

What is your proposed solution?

We can display a warning message when data-wp-ignore is used and remove it in a subsequent WordPress release. Alternatively, it can even be removed directly, as it is not documented and it's improbable that developers are using it.

Activity

  1. Sahil1617 commented on Jul 23, 2025

    @Sahil1617
    Contributor

    Hi @DAreRodz 👋

    Thanks for highlighting this cleanup opportunity.

    To start, I plan to:

    • Locate where data-wp-ignore is currently being processed.
    • Add a console warning to inform developers that this directive is deprecated.
    • Maintain backward compatibility for now (as suggested), and prepare for its full removal in a future release.

    Let me know if that sounds good or if there are any additional considerations I should be aware of. Looking forward to contributing!

  2. DAreRodz commented on Jul 28, 2025

    @DAreRodz
    ContributorAuthor

    Hi, @Sahil1617. 👋 If you're willing to work on this issue, the data-wp-ignore implementation is in the /packages/interactivity/src/directives.tsx file.

    // data-wp-ignore
    directive(
    'ignore',
    ( {
    element: {
    type: Type,
    props: { innerHTML, ...rest },
    },
    }: {
    element: any;
    } ) => {
    // Preserve the initial inner HTML.
    const cached = useMemo( () => innerHTML, [] );
    return createElement( Type, {
    dangerouslySetInnerHTML: { __html: cached },
    ...rest,
    } );
    }
    );

    You can use the warn function, like the data-wp-context directive does, to show a deprecation message to developers:

    if ( ! isPlainObject( value ) ) {
    warn(
    `The value of data-wp-context in "${ namespace }" store must be a valid stringified JSON object.`
    );
    }

  3. Sahil1617 commented on Jul 28, 2025

    @Sahil1617
    Contributor

    Thanks for the pointer, @DAreRodz! 🙌

    I've located the data-wp-ignore directive in /packages/interactivity/src/directives.tsx (lines 592–610), and I plan to:

    1. Add a warn() call within the directive to notify developers that data-wp-ignore is deprecated.
    2. Keep the existing functionality intact for now to ensure backward compatibility.
    3. Add a comment indicating that this directive is scheduled for removal in a future release (e.g., WordPress 6.10 or later).

    I'll open a PR shortly with the changes. Please let me know if you'd prefer any adjustments to the messaging or approach.

    Looking forward to contributing! 🚀

  4. sirreal commented on Aug 27, 2025

    @sirreal
    Member

    Are there alternatives to the ignore directive? I saw the deprecation message recently, but it's unclear whether I can do anything about it or where to go for more information. A link to some explanation in the deprecation message would be nice.

  5. emeaguiar commented on Mar 12, 2026

    @emeaguiar

    +1 on alternatives? A third part script was adding an onClick to the markup on one site, this triggered an error in the interactivity api and data-wp-ignore fixes it, is there a way to get around this now?

  6. luisherranz commented on Mar 13, 2026

    @luisherranz
    Member

    Can you give a more concrete example of the HTML and what is failing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions