Skip to content

Commit 263e6bc

Browse files
authored
Merge pull request #212 from catap/a-attr-download
Introduced attribute `download` for anchor
2 parents 01290b7 + 7c851d8 commit 263e6bc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

scalatags/src/scalatags/generic/Attrs.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,22 @@ trait InputAttrs[Builder, Output <: FragT, FragT] extends GlobalAttrs[Builder, O
813813
lazy val widthA = attr("width") // TODO: Conflicts with "width" in Styles
814814
}
815815

816+
trait AnchorElementAttrs[Builder, Output<:FragT, FragT] extends Util[Builder, Output, FragT] {
817+
/**
818+
* Prompts the user to save the linked URL instead of navigating to it. Can be used with or without a value:
819+
* - Without a value, the browser will suggest a filename/extension, generated from various sources:
820+
* * The Content-Disposition HTTP header
821+
* * The final segment in the URL path
822+
* * The media type (from the (Content-Type header, the start of a data: URL, or Blob.type for a blob: URL)
823+
* - Defining a value suggests it as the filename. / and \ characters are converted to underscores _.
824+
* Filesystems may forbid other characters in filenames, so browsers will adjust the suggested name if necessary.
825+
*
826+
* MDN
827+
*/
828+
lazy val download = attr("download")
829+
}
830+
831+
816832
/**
817833
* Trait containing the contents of the [[Attrs]] module, so they can be
818834
* mixed in to other objects if needed. This should contain "all" attributes
@@ -826,6 +842,7 @@ trait Attrs[Builder, Output <: FragT, FragT] extends InputAttrs[Builder, Output,
826842
with MouseEventAttrs[Builder, Output, FragT]
827843
with WindowEventAttrs[Builder, Output, FragT]
828844
with FormEventAttrs[Builder, Output, FragT]
845+
with AnchorElementAttrs[Builder, Output, FragT]
829846
{
830847
/**
831848
* This is the single required attribute for anchors defining a hypertext

0 commit comments

Comments
 (0)