Skip to content

Commit 865263d

Browse files
impronunciabletimneutkens
authored andcommitted
Fix/amp example (vercel#1755)
* Using developit/unfetch as the Fetch API polyfill * Fixed amp example checking if the amp attribute is already present * Fix lint
1 parent f82e529 commit 865263d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/with-amp/pages/_document.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import Document, { Head } from 'next/document'
22
import { DOMProperty } from 'react-dom/lib/ReactInjection'
3+
import { properties as DOMProperties } from 'react-dom/lib/DOMProperty'
34

45
// By default React limit the set of valid DOM elements and attributes
56
// (https://github.com/facebook/react/issues/140) this config whitelist
67
// Amp elements/attributes
7-
DOMProperty.injectDOMPropertyConfig({
8-
Properties: { amp: DOMProperty.MUST_USE_ATTRIBUTE },
9-
isCustomAttribute: attributeName => attributeName.startsWith('amp-')
10-
})
8+
if (typeof DOMProperties.amp === 'undefined') {
9+
DOMProperty.injectDOMPropertyConfig({
10+
Properties: { amp: DOMProperty.MUST_USE_ATTRIBUTE },
11+
isCustomAttribute: attributeName => attributeName.startsWith('amp-')
12+
})
13+
}
1114

1215
export default class MyDocument extends Document {
1316
render () {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy