Skip to content

Commit 76826b5

Browse files
committed
s/GRANDFATHERED/EXEMPTED/
PiperOrigin-RevId: 280045190
1 parent f78eb35 commit 76826b5

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

transformer/transformers/unusedextensions.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ import (
2222
"golang.org/x/net/html"
2323
)
2424

25-
// elementGrandfatheredExtensions are names of elements that indicate usage
25+
// elementExemptedExtensions are names of elements that indicate usage
2626
// of an equally named extension. e.g. If the <amp-iframe> element is present,
2727
// 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": ""}
2929

30-
// differentElementGrandfatheredExtensions are names of extensions that indicate
30+
// differentElementExemptedExtensions are names of extensions that indicate
3131
// usage by a differently named tag or tag with attribute. e.g. If the <form>
3232
// 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": ""}
3434

35-
// UnusedExtensions removes script tags for unused grandfathered extensions.
35+
// UnusedExtensions removes script tags for unused legacy-exempted extensions.
3636
func UnusedExtensions(e *Context) error {
3737
extensionsUsed := make(map[string]string)
3838
for n := e.DOM.RootNode; n != nil; n = htmlnode.Next(n) {
3939
insertMatchingExtensions(n, extensionsUsed)
4040
}
4141
for c := e.DOM.HeadNode.FirstChild; c != nil; c = c.NextSibling {
4242
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) {
4444
htmlnode.RemoveNode(&c)
4545
}
4646
}
@@ -55,8 +55,7 @@ func UnusedExtensions(e *Context) error {
5555
// extension that's needed).
5656
//
5757
// 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.
6059
func insertMatchingExtensions(n *html.Node, e map[string]string) {
6160
if n.Type != html.ElementNode {
6261
return
@@ -76,7 +75,7 @@ func insertMatchingExtensions(n *html.Node, e map[string]string) {
7675
case "template":
7776
e["amp-mustache"] = ""
7877
default:
79-
if _, ok := elementGrandfatheredExtensions[n.Data]; ok {
78+
if _, ok := elementExemptedExtensions[n.Data]; ok {
8079
e[n.Data] = ""
8180
}
8281
}

transformer/transformers/unusedextensions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func TestUnusedExtensions(t *testing.T) {
212212
"</body></html>"),
213213
},
214214
{
215-
Desc: "keeps non-grandfathered extension",
215+
Desc: "keeps non-legacy-exempted extension",
216216
Input: tt.Concat(tt.Doctype,
217217
"<html ⚡><head>",
218218
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime,

0 commit comments

Comments
 (0)