Home / File/ isAttributeNameSafe.js — react Source File

isAttributeNameSafe.js — react Source File

Architecture documentation for isAttributeNameSafe.js, a javascript file in the react codebase. 1 imports, 4 dependents.

File javascript BabelCompiler Validation 1 imports 4 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  36fcaad4_7e57_5971_700b_f932b635486a["isAttributeNameSafe.js"]
  a413acd5_7541_e904_f255_d4dd9b5e5bc1["hasOwnProperty"]
  36fcaad4_7e57_5971_700b_f932b635486a --> a413acd5_7541_e904_f255_d4dd9b5e5bc1
  390123a6_56c3_29ed_a331_44deb86078d6["DOMPropertyOperations.js"]
  390123a6_56c3_29ed_a331_44deb86078d6 --> 36fcaad4_7e57_5971_700b_f932b635486a
  4ae326e8_2c2e_2843_d5a5_16edbddd103a["ReactFizzConfigDOM.js"]
  4ae326e8_2c2e_2843_d5a5_16edbddd103a --> 36fcaad4_7e57_5971_700b_f932b635486a
  c1dc9c2d_185d_8161_e658_7c3c75929b15["ReactDOMInvalidARIAHook.js"]
  c1dc9c2d_185d_8161_e658_7c3c75929b15 --> 36fcaad4_7e57_5971_700b_f932b635486a
  7bf34687_c093_d285_ad96_da146989d7e6["ReactDOMUnknownPropertyHook.js"]
  7bf34687_c093_d285_ad96_da146989d7e6 --> 36fcaad4_7e57_5971_700b_f932b635486a
  style 36fcaad4_7e57_5971_700b_f932b635486a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import hasOwnProperty from 'shared/hasOwnProperty';

const ATTRIBUTE_NAME_START_CHAR =
  ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
export const ATTRIBUTE_NAME_CHAR: string =
  ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';

const VALID_ATTRIBUTE_NAME_REGEX: RegExp = new RegExp(
  '^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$',
);

const illegalAttributeNameCache: {[string]: boolean} = {};
const validatedAttributeNameCache: {[string]: boolean} = {};

export default function isAttributeNameSafe(attributeName: string): boolean {
  if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
    return true;
  }
  if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
    return false;
  }
  if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
    validatedAttributeNameCache[attributeName] = true;
    return true;
  }
  illegalAttributeNameCache[attributeName] = true;
  if (__DEV__) {
    console.error('Invalid attribute name: `%s`', attributeName);
  }
  return false;
}

Domain

Subdomains

Dependencies

  • hasOwnProperty

Frequently Asked Questions

What does isAttributeNameSafe.js do?
isAttributeNameSafe.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in isAttributeNameSafe.js?
isAttributeNameSafe.js defines 1 function(s): isAttributeNameSafe.
What does isAttributeNameSafe.js depend on?
isAttributeNameSafe.js imports 1 module(s): hasOwnProperty.
What files import isAttributeNameSafe.js?
isAttributeNameSafe.js is imported by 4 file(s): DOMPropertyOperations.js, ReactDOMInvalidARIAHook.js, ReactDOMUnknownPropertyHook.js, ReactFizzConfigDOM.js.
Where is isAttributeNameSafe.js in the architecture?
isAttributeNameSafe.js is located at packages/react-dom-bindings/src/shared/isAttributeNameSafe.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-dom-bindings/src/shared).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free