From e5ef43f6c37786c6902be410aab5155beb27e10f Mon Sep 17 00:00:00 2001 From: Sid Vishnoi Date: Sat, 21 Nov 2020 22:33:20 +0530 Subject: [PATCH] Is. #879: add loading attribute for img, iframe (#902) Closes #879 --- include/tidyenum.h | 1 + src/attrdict.c | 2 ++ src/attrs.c | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/include/tidyenum.h b/include/tidyenum.h index e34d1ca..8fd2ce9 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -1083,6 +1083,7 @@ typedef enum TidyAttr_LAST_VISIT, /**< LAST_VISIT= */ TidyAttr_LEFTMARGIN, /**< LEFTMARGIN= */ TidyAttr_LINK, /**< LINK= */ + TidyAttr_LOADING, /**< LOADING= */ TidyAttr_LONGDESC, /**< LONGDESC= */ TidyAttr_LOWSRC, /**< LOWSRC= */ TidyAttr_MARGINHEIGHT, /**< MARGINHEIGHT= */ diff --git a/src/attrdict.c b/src/attrdict.c index c92d64e..9f9cc9a 100644 --- a/src/attrdict.c +++ b/src/attrdict.c @@ -1631,6 +1631,7 @@ const AttrVersion TY_(W3CAttrsFor_IFRAME)[] = { TidyAttr_FRAMEBORDER, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx }, { TidyAttr_HEIGHT, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, { TidyAttr_ID, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, /* CORE override */ + { TidyAttr_LOADING, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, { TidyAttr_LONGDESC, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx }, { TidyAttr_MARGINHEIGHT, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx }, { TidyAttr_MARGINWIDTH, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx }, @@ -1664,6 +1665,7 @@ const AttrVersion TY_(W3CAttrsFor_IMG)[] = { TidyAttr_ID, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10|HT50|XH50 }, /* CORE override */ { TidyAttr_ISMAP, HT20|HT32|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx|HT50|XH50 }, { TidyAttr_LANG, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|xxxx|xxxx|HT50|XH50 }, /* CORE override */ + { TidyAttr_LOADING, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, { TidyAttr_LONGDESC, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10|xxxx|xxxx }, { TidyAttr_NAME, xxxx|xxxx|xxxx|H41T|X10T|xxxx|H41F|X10F|xxxx|H41S|xxxx|xxxx|xxxx|xxxx|xxxx }, { TidyAttr_OnCLICK, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx|HT50|XH50 }, /* CORE override */ diff --git a/src/attrs.c b/src/attrs.c index ff4f076..b03a79e 100644 --- a/src/attrs.c +++ b/src/attrs.c @@ -47,6 +47,7 @@ static AttrCheck CheckVType; static AttrCheck CheckScroll; static AttrCheck CheckTextDir; static AttrCheck CheckLang; +static AttrCheck CheckLoading; static AttrCheck CheckType; static AttrCheck CheckRDFaSafeCURIE; static AttrCheck CheckRDFaTerm; @@ -66,6 +67,7 @@ static AttrCheck CheckRDFaPrefix; #define CH_CLEAR CheckClear #define CH_BORDER CheckBool /* kludge */ #define CH_LANG CheckLang +#define CH_LOADING CheckLoading #define CH_BOOL CheckBool #define CH_COLS NULL #define CH_NUMBER CheckNumber @@ -177,6 +179,7 @@ static const Attribute attribute_defs [] = { TidyAttr_LAST_VISIT, "last_visit", CH_PCDATA }, /* A */ { TidyAttr_LEFTMARGIN, "leftmargin", CH_NUMBER }, /* used on BODY */ { TidyAttr_LINK, "link", CH_COLOR }, /* BODY */ + { TidyAttr_LOADING, "loading", CH_LOADING }, /* IMG, IFRAME */ { TidyAttr_LONGDESC, "longdesc", CH_URL }, /* IMG */ { TidyAttr_LOWSRC, "lowsrc", CH_URL }, /* IMG */ { TidyAttr_MARGINHEIGHT, "marginheight", CH_NUMBER }, /* FRAME, IFRAME, BODY */ @@ -2046,6 +2049,13 @@ void CheckLang( TidyDocImpl* doc, Node *node, AttVal *attval) } } +/* checks loading attribute */ +void CheckLoading( TidyDocImpl* doc, Node *node, AttVal *attval) +{ + ctmbstr const values[] = {"lazy", "eager", NULL}; + CheckAttrValidity( doc, node, attval, values ); +} + /* checks type attribute */ void CheckType( TidyDocImpl* doc, Node *node, AttVal *attval) {