<commit_before>// Copyright 2004-present Facebook. All Rights Reserved.

#include "UIManager.h"

#include <react/core/ShadowNodeFragment.h>
#include <react/debug/SystraceSection.h>
#include <react/utils/TimeUtils.h>

namespace facebook {
namespace react {

SharedShadowNode UIManager::createNode(
    Tag tag,
    const ComponentName &name,
    SurfaceId surfaceId,
    const RawProps &rawProps,
    SharedEventTarget eventTarget) const {
  SystraceSection s("UIManager::createNode");

  auto &componentDescriptor = componentDescriptorRegistry_->at(name);
  auto fallbackDescriptor =
      componentDescriptorRegistry_->getFallbackComponentDescriptor();

  const auto &props = componentDescriptor.cloneProps(nullptr, rawProps);
  const auto &state = componentDescriptor.createInitialState(props);

  auto shadowNode = componentDescriptor.createShadowNode({
      /* .tag = */ tag,
      /* .rootTag = */ surfaceId,
      /* .props = */
      fallbackDescriptor != nullptr &&
              fallbackDescriptor->getComponentHandle() ==
                  componentDescriptor.getComponentHandle()
          ? componentDescriptor.cloneProps(
                nullptr, RawProps(folly::dynamic::object("name", name)))
          : props,
      /* .eventEmitter = */
      componentDescriptor.createEventEmitter(std::move(eventTarget), tag),
      /* .children = */ ShadowNodeFragment::childrenPlaceholder(),
      /* .localData = */ ShadowNodeFragment::localDataPlaceholder(),
      /* .state = */ state,
  });

  if (delegate_) {
    delegate_->uiManagerDidCreateShadowNode(shadowNode);
  }

  return shadowNode;
}

SharedShadowNode UIManager::cloneNode(
    const SharedShadowNode &shadowNode,
    const SharedShadowNodeSharedList &children,
    const RawProps *rawProps) const {
  SystraceSection s("UIManager::cloneNode");

  auto &componentDescriptor = shadowNode->getComponentDescriptor();<commit_msg>Fabric: preserve original props when using fallback component<commit_after>// Copyright 2004-present Facebook. All Rights Reserved.

#include "UIManager.h"

#include <react/core/ShadowNodeFragment.h>
#include <react/debug/SystraceSection.h>
#include <react/utils/TimeUtils.h>

namespace facebook {
namespace react {

SharedShadowNode UIManager::createNode(
    Tag tag,
    const ComponentName &name,
    SurfaceId surfaceId,
    const RawProps &rawProps,
    SharedEventTarget eventTarget) const {
  SystraceSection s("UIManager::createNode");

  auto &componentDescriptor = componentDescriptorRegistry_->at(name);
  auto fallbackDescriptor =
      componentDescriptorRegistry_->getFallbackComponentDescriptor();

  const auto &props = componentDescriptor.cloneProps(nullptr, rawProps);
  const auto &state = componentDescriptor.createInitialState(props);

  auto shadowNode = componentDescriptor.createShadowNode({
      /* .tag = */ tag,
      /* .rootTag = */ surfaceId,
      /* .props = */
      fallbackDescriptor != nullptr &&
              fallbackDescriptor->getComponentHandle() ==
                  componentDescriptor.getComponentHandle()
          ? componentDescriptor.cloneProps(
                props, RawProps(folly::dynamic::object("name", name)))
          : props,
      /* .eventEmitter = */
      componentDescriptor.createEventEmitter(std::move(eventTarget), tag),
      /* .children = */ ShadowNodeFragment::childrenPlaceholder(),
      /* .localData = */ ShadowNodeFragment::localDataPlaceholder(),
      /* .state = */ state,
  });

  if (delegate_) {
    delegate_->uiManagerDidCreateShadowNode(shadowNode);
  }

  return shadowNode;
}

SharedShadowNode UIManager::cloneNode(
    const SharedShadowNode &shadowNode,
    const SharedShadowNodeSharedList &children,
    const RawProps *rawProps) const {
  SystraceSection s("UIManager::cloneNode");

  auto &componentDescriptor = shadowNode->getComponentDescriptor();
{'fraction_non_alphanumeric': 0.11119791666666666, 'fraction_numerical': 0.0020833333333333333, 'mean_word_length': 3.9497422680412373, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5819472', 'n_tokens_mistral': 1024, 'n_tokens_neox': 1009, 'n_words': 204}