@@ -22,25 +22,25 @@ import (
22
22
"golang.org/x/net/html"
23
23
)
24
24
25
- // elementGrandfatheredExtensions are names of elements that indicate usage
25
+ // elementExemptedExtensions are names of elements that indicate usage
26
26
// of an equally named extension. e.g. If the <amp-iframe> element is present,
27
27
// then the amp-iframe extension is in use. Used by insertMatchingExtensions.
28
- var /* const */ elementGrandfatheredExtensions = map [string ]string {"amp-accordion" : "" , "amp-ad" : "" , "amp-anim" : "" , "amp-apester-media" : "" , "amp-audio" : "" , "amp-brid-player" : "" , "amp-brightcove" : "" , "amp-call-tracking" : "" , "amp-carousel" : "" , "amp-dailymotion" : "" , "amp-experiment" : "" , "amp-facebook" : "" , "amp-fit-text" : "" , "amp-font" : "" , "amp-fx-flying-carpet" : "" , "amp-gfycat" : "" , "amp-iframe" : "" , "amp-image-lightbox" : "" , "amp-instagram" : "" , "amp-install-serviceworker" : "" , "amp-izlesene" : "" , "amp-jwplayer" : "" , "amp-kaltura-player" : "" , "amp-lightbox" : "" , "amp-list" : "" , "amp-live-list" : "" , "amp-o2-player" : "" , "amp-pinterest" : "" , "amp-reach-player" : "" , "amp-selector" : "" , "amp-sidebar" : "" , "amp-social-share" : "" , "amp-soundcloud" : "" , "amp-springboard-player" : "" , "amp-sticky-ad" : "" , "amp-twitter" : "" , "amp-user-notification" : "" , "amp-vimeo" : "" , "amp-vine" : "" , "amp-youtube" : "" }
28
+ var /* const */ elementExemptedExtensions = map [string ]string {"amp-accordion" : "" , "amp-ad" : "" , "amp-anim" : "" , "amp-apester-media" : "" , "amp-audio" : "" , "amp-brid-player" : "" , "amp-brightcove" : "" , "amp-call-tracking" : "" , "amp-carousel" : "" , "amp-dailymotion" : "" , "amp-experiment" : "" , "amp-facebook" : "" , "amp-fit-text" : "" , "amp-font" : "" , "amp-fx-flying-carpet" : "" , "amp-gfycat" : "" , "amp-iframe" : "" , "amp-image-lightbox" : "" , "amp-instagram" : "" , "amp-install-serviceworker" : "" , "amp-izlesene" : "" , "amp-jwplayer" : "" , "amp-kaltura-player" : "" , "amp-lightbox" : "" , "amp-list" : "" , "amp-live-list" : "" , "amp-o2-player" : "" , "amp-pinterest" : "" , "amp-reach-player" : "" , "amp-selector" : "" , "amp-sidebar" : "" , "amp-social-share" : "" , "amp-soundcloud" : "" , "amp-springboard-player" : "" , "amp-sticky-ad" : "" , "amp-twitter" : "" , "amp-user-notification" : "" , "amp-vimeo" : "" , "amp-vine" : "" , "amp-youtube" : "" }
29
29
30
- // differentElementGrandfatheredExtensions are names of extensions that indicate
30
+ // differentElementExemptedExtensions are names of extensions that indicate
31
31
// usage by a differently named tag or tag with attribute. e.g. If the <form>
32
32
// element is present, then the amp-form extension is in use.
33
- var /* const */ differentElementGrandfatheredExtensions = map [string ]string {"amp-access" : "" , "amp-form" : "" , "amp-mustache" : "" }
33
+ var /* const */ differentElementExemptedExtensions = map [string ]string {"amp-access" : "" , "amp-form" : "" , "amp-mustache" : "" }
34
34
35
- // UnusedExtensions removes script tags for unused grandfathered extensions.
35
+ // UnusedExtensions removes script tags for unused legacy-exempted extensions.
36
36
func UnusedExtensions (e * Context ) error {
37
37
extensionsUsed := make (map [string ]string )
38
38
for n := e .DOM .RootNode ; n != nil ; n = htmlnode .Next (n ) {
39
39
insertMatchingExtensions (n , extensionsUsed )
40
40
}
41
41
for c := e .DOM .HeadNode .FirstChild ; c != nil ; c = c .NextSibling {
42
42
if ext , ok := amphtml .AMPExtensionName (c ); ok {
43
- if len (ext ) > 0 && (isStringKeyInMap (ext , elementGrandfatheredExtensions ) || isStringKeyInMap (ext , differentElementGrandfatheredExtensions )) && ! isStringKeyInMap (ext , extensionsUsed ) {
43
+ if len (ext ) > 0 && (isStringKeyInMap (ext , elementExemptedExtensions ) || isStringKeyInMap (ext , differentElementExemptedExtensions )) && ! isStringKeyInMap (ext , extensionsUsed ) {
44
44
htmlnode .RemoveNode (& c )
45
45
}
46
46
}
@@ -55,8 +55,7 @@ func UnusedExtensions(e *Context) error {
55
55
// extension that's needed).
56
56
//
57
57
// This logic should match the requires_extension fields in the
58
- // validator-*.protoascii files that correspond to GRANDFATHERED
59
- // extension_specs.
58
+ // validator-*.protoascii files that correspond to EXEMPTED extension_specs.
60
59
func insertMatchingExtensions (n * html.Node , e map [string ]string ) {
61
60
if n .Type != html .ElementNode {
62
61
return
@@ -76,7 +75,7 @@ func insertMatchingExtensions(n *html.Node, e map[string]string) {
76
75
case "template" :
77
76
e ["amp-mustache" ] = ""
78
77
default :
79
- if _ , ok := elementGrandfatheredExtensions [n .Data ]; ok {
78
+ if _ , ok := elementExemptedExtensions [n .Data ]; ok {
80
79
e [n .Data ] = ""
81
80
}
82
81
}
0 commit comments