Skip to content

Commit

Permalink
Is. #879: add loading attribute for img, iframe (#902)
Browse files Browse the repository at this point in the history
Closes #879
  • Loading branch information
sidvishnoi authored Nov 21, 2020
1 parent d6cd253 commit e5ef43f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/tidyenum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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= */
Expand Down
2 changes: 2 additions & 0 deletions src/attrdict.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 */
Expand Down
10 changes: 10 additions & 0 deletions src/attrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit e5ef43f

Please sign in to comment.