* Hides or shows the fallback, if available. This function must only * be called inside a mutate context. * @param {boolean} show * @package @final
(show)
| 1970 | * @package @final |
| 1971 | */ |
| 1972 | toggleFallback(show) { |
| 1973 | assertNotTemplate(this); |
| 1974 | const resourceState = this.getResource_().getState(); |
| 1975 | // Do not show fallback before layout |
| 1976 | if ( |
| 1977 | !this.R1() && |
| 1978 | show && |
| 1979 | (resourceState == ResourceState_Enum.NOT_BUILT || |
| 1980 | resourceState == ResourceState_Enum.NOT_LAID_OUT || |
| 1981 | resourceState == ResourceState_Enum.READY_FOR_LAYOUT) |
| 1982 | ) { |
| 1983 | return; |
| 1984 | } |
| 1985 | // This implementation is notably less efficient then placeholder |
| 1986 | // toggling. The reasons for this are: (a) "not supported" is the state of |
| 1987 | // the whole element, (b) some relayout is expected and (c) fallback |
| 1988 | // condition would be rare. |
| 1989 | this.classList.toggle('amp-notsupported', show); |
| 1990 | if (show == true) { |
| 1991 | const fallbackElement = this.getFallback(); |
| 1992 | if (fallbackElement) { |
| 1993 | Services.ownersForDoc(this.getAmpDoc()).scheduleLayout( |
| 1994 | this, |
| 1995 | fallbackElement |
| 1996 | ); |
| 1997 | } |
| 1998 | } |
| 1999 | } |
| 2000 | |
| 2001 | /** |
| 2002 | * An implementation can call this method to signal to the element that |
nothing calls this directly
no test coverage detected