MCPcopy
hub / github.com/ampproject/amphtml / togglePlaceholder

Method togglePlaceholder

src/custom-element.js:1937–1955  ·  view source on GitHub ↗

* Hides or shows the placeholder, if available. * @param {boolean} show * @package @final

(show)

Source from the content-addressed store, hash-verified

1935 * @package @final
1936 */
1937 togglePlaceholder(show) {
1938 assertNotTemplate(this);
1939 if (show) {
1940 const placeholder = this.getPlaceholder();
1941 if (placeholder) {
1942 dev().assertElement(placeholder).classList.remove('amp-hidden');
1943 }
1944 } else {
1945 const placeholders = query.childElementsByAttr(this, 'placeholder');
1946 for (let i = 0; i < placeholders.length; i++) {
1947 // Don't toggle elements with a native placeholder property
1948 // e.g. input, textarea
1949 if (isInputPlaceholder(placeholders[i])) {
1950 continue;
1951 }
1952 placeholders[i].classList.add('amp-hidden');
1953 }
1954 }
1955 }
1956
1957 /**
1958 * Returns an optional fallback element for this custom element.

Callers 1

renderStartedMethod · 0.95

Calls 7

getPlaceholderMethod · 0.95
devFunction · 0.90
assertNotTemplateFunction · 0.85
isInputPlaceholderFunction · 0.85
assertElementMethod · 0.80
removeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected