MCPcopy Index your code
hub / github.com/react/react / pushStartAnchor

Function pushStartAnchor

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js:1919–1968  ·  view source on GitHub ↗
(
  target: Array<Chunk | PrecomputedChunk>,
  props: Object,
  formatContext: FormatContext,
)

Source from the content-addressed store, hash-verified

1917}
1918
1919function pushStartAnchor(
1920 target: Array<Chunk | PrecomputedChunk>,
1921 props: Object,
1922 formatContext: FormatContext,
1923): ReactNodeList {
1924 target.push(startChunkForTag('a'));
1925
1926 let children = null;
1927 let innerHTML = null;
1928 for (const propKey in props) {
1929 if (hasOwnProperty.call(props, propKey)) {
1930 const propValue = props[propKey];
1931 if (propValue == null) {
1932 continue;
1933 }
1934 switch (propKey) {
1935 case 'children':
1936 children = propValue;
1937 break;
1938 case 'dangerouslySetInnerHTML':
1939 innerHTML = propValue;
1940 break;
1941 case 'href':
1942 if (propValue === '') {
1943 // Empty `href` is special on anchors so we're short-circuiting here.
1944 // On other tags it should trigger a warning
1945 pushStringAttribute(target, 'href', '');
1946 } else {
1947 pushAttribute(target, propKey, propValue);
1948 }
1949 break;
1950 default:
1951 pushAttribute(target, propKey, propValue);
1952 break;
1953 }
1954 }
1955 }
1956
1957 pushViewTransitionAttributes(target, formatContext);
1958
1959 target.push(endOfStartTag);
1960 pushInnerHTML(target, innerHTML, children);
1961 if (typeof children === 'string') {
1962 // Special case children as a string to avoid the unnecessary comment.
1963 // TODO: Remove this special case after the general optimization is in place.
1964 target.push(stringToChunk(encodeHTMLTextNode(children)));
1965 return null;
1966 }
1967 return children;
1968}
1969
1970function pushStartObject(
1971 target: Array<Chunk | PrecomputedChunk>,

Callers 1

pushStartInstanceFunction · 0.85

Calls 8

stringToChunkFunction · 0.90
startChunkForTagFunction · 0.85
pushStringAttributeFunction · 0.85
pushAttributeFunction · 0.85
pushInnerHTMLFunction · 0.85
encodeHTMLTextNodeFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected