Skip to content

img attrs: srcset, currentSrc, sizes, referrerPolicy, decoding, loading #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions src/Web/HTML/HTMLImageElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,46 @@ exports.setSrc = function (src) {

// ----------------------------------------------------------------------------

exports.srcset = function (image) {
return function () {
return image.srcset;
};
};

exports.setSrcset = function (srcset) {
return function (image) {
return function () {
image.srcset = srcset;
};
};
};

// ----------------------------------------------------------------------------

exports.sizes = function (image) {
return function () {
return image.sizes;
};
};

exports.setSizes = function (sizes) {
return function (image) {
return function () {
image.sizes = sizes;
};
};
};

// ----------------------------------------------------------------------------

exports.currentSrc = function (image) {
return function () {
return image.currentSrc;
};
};

// ----------------------------------------------------------------------------

exports.crossOrigin = function (image) {
return function () {
return image.crossOrigin;
Expand Down Expand Up @@ -143,6 +183,55 @@ exports.naturalHeight = function (image) {

// ----------------------------------------------------------------------------

exports.referrerPolicy = function (image) {
return function () {
return image.referrerPolicy;
};
};

exports.setReferrerPolicy = function (referrerPolicy) {
return function (image) {
return function () {
image.referrerPolicy = referrerPolicy;
};
};
};


// ----------------------------------------------------------------------------

exports.decoding = function (image) {
return function () {
return image.decoding;
};
};

exports.setDecoding = function (decoding) {
return function (image) {
return function () {
image.decoding = decoding;
};
};
};

// ----------------------------------------------------------------------------

exports.loading = function (image) {
return function () {
return image.loading;
};
};

exports.setLoading = function (loading) {
return function (image) {
return function () {
image.loading = loading;
};
};
};

// ----------------------------------------------------------------------------

exports.complete = function (image) {
return function () {
return image.complete;
Expand Down
27 changes: 27 additions & 0 deletions src/Web/HTML/HTMLImageElement.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module Web.HTML.HTMLImageElement
, setAlt
, src
, setSrc
, srcset
, setSrcset
, currentSrc
, crossOrigin
, setCrossOrigin
, useMap
Expand All @@ -32,6 +35,12 @@ module Web.HTML.HTMLImageElement
, setHeight
, naturalWidth
, naturalHeight
, referrerPolicy
, setReferrerPolicy
, decoding
, setDecoding
, loading
, setLoading
, complete
) where

Expand Down Expand Up @@ -101,6 +110,14 @@ foreign import setAlt :: String -> HTMLImageElement -> Effect Unit
foreign import src :: HTMLImageElement -> Effect String
foreign import setSrc :: String -> HTMLImageElement -> Effect Unit

foreign import srcset :: HTMLImageElement -> Effect String
foreign import setSrcset :: String -> HTMLImageElement -> Effect Unit

foreign import currentSrc :: HTMLImageElement -> Effect String

foreign import sizes :: HTMLImageElement -> Effect String
foreign import setSizes :: String -> HTMLImageElement -> Effect Unit

foreign import crossOrigin :: HTMLImageElement -> Effect String
foreign import setCrossOrigin :: String -> HTMLImageElement -> Effect Unit

Expand All @@ -118,4 +135,14 @@ foreign import setHeight :: Int -> HTMLImageElement -> Effect Unit

foreign import naturalWidth :: HTMLImageElement -> Effect Int
foreign import naturalHeight :: HTMLImageElement -> Effect Int

foreign import referrerPolicy :: HTMLImageElement -> Effect String
foreign import setReferrerPolicy :: String -> HTMLImageElement -> Effect Unit

foreign import decoding :: HTMLImageElement -> Effect String
foreign import setDecoding :: String -> HTMLImageElement -> Effect Unit

foreign import loading :: HTMLImageElement -> Effect String
foreign import setLoading :: String -> HTMLImageElement -> Effect Unit

foreign import complete :: HTMLImageElement -> Effect Boolean