Skip to content

Commit

Permalink
Update with isdebug, rephrase error
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed May 7, 2024
1 parent df4bb57 commit 9293b4b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
7 changes: 2 additions & 5 deletions packages/interactivity/src/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { deepSignal, peek } from 'deepsignal';
import { useWatch, useInit } from './utils';
import { directive, getScope, getEvaluate } from './hooks';
import { kebabToCamelCase } from './utils/kebab-to-camelcase';
import { isDebug } from './constants';

// Assigned objects should be ignore during proxification.
const contextAssignedObjects = new WeakMap();
Expand Down Expand Up @@ -242,11 +243,7 @@ export default () => {
if ( defaultEntry ) {
const { namespace, value } = defaultEntry;
// Check that the value is a JSON object. Send a console warning if not.
if (
typeof SCRIPT_DEBUG !== 'undefined' &&
SCRIPT_DEBUG === true &&
! isPlainObject( value )
) {
if ( isDebug && ! isPlainObject( value ) ) {
// eslint-disable-next-line no-console
console.warn(
`The value of data-wp-context in "${ namespace }" store must be a valid stringified JSON object.`
Expand Down
2 changes: 1 addition & 1 deletion packages/interactivity/src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const resolve = ( path, namespace ) => {
if ( isDebug ) {
// eslint-disable-next-line no-console
console.warn(
`The namespace "${ namespace }" defined in "data-wp-interactive" does not match with the store.`
`There was an error when trying to resolve the path "${ path }" in the namespace "${ namespace }".`
);
}
}
Expand Down
9 changes: 2 additions & 7 deletions packages/interactivity/src/vdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { h } from 'preact';
/**
* Internal dependencies
*/
import { directivePrefix as p } from './constants';
import { isDebug, directivePrefix as p } from './constants';

const ignoreAttr = `data-${ p }-ignore`;
const islandAttr = `data-${ p }-interactive`;
Expand Down Expand Up @@ -120,12 +120,7 @@ export function toVdom( root ) {
( obj, [ name, ns, value ] ) => {
const directiveMatch = directiveParser.exec( name );
if ( directiveMatch === null ) {
if (
// @ts-expect-error This is a debug-only warning.
typeof SCRIPT_DEBUG !== 'undefined' &&
// @ts-expect-error This is a debug-only warning.
SCRIPT_DEBUG === true
) {
if ( isDebug ) {
// eslint-disable-next-line no-console
console.warn( `Invalid directive: ${ name }.` );
}
Expand Down

0 comments on commit 9293b4b

Please sign in to comment.