Skip to content

Commit

Permalink
#6: added obsolete scrolling attribute to iframe as firefox provides …
Browse files Browse the repository at this point in the history
…no CSS to remove the scrollbars
  • Loading branch information
DennisBirkholz committed Sep 1, 2017
1 parent 6796587 commit 8a05b48
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/Html/Iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,66 @@ final public function clearSandboxFeatures() : self

// from HeightWidthAttributesTrait

######################################################################
# scrolling attribute LEGACY! #
######################################################################

/**
* Provide a scroll bar only when needed
*/
const SCROLLING_AUTO = 'auto';

/**
* Always provide a scroll bar
*/
const SCROLLING_YES = 'yes';

/**
* Never provide a scroll bar
*/
const SCROLLING_NO = 'no';

/**
* @var string
* @link https://www.w3.org/TR/html401/present/frames.html#adef-scrolling
*/
private $scrolling;

/**
* Get the scrollbars setting
* WARNING: obsolete in HTML5
*/
final public function getScrolling() : string
{
return $this->scrolling;
}

/**
* Check whether the scrollbars setting is set
* WARNING: obsolete in HTML5
*/
final public function hasScrolling() : bool
{
return ($this->scrolling !== null);
}

/**
* Set the scrollbars setting
* WARNING: obsolete in HTML5
*/
final public function setScrolling(string $scrolling = null) : self
{
if ($scrolling !== null && $scrolling !== self::SCROLLING_AUTO && $scrolling !== self::SCROLLING_YES && $scrolling !== self::SCROLLING_NO) {
throw new \InvalidArgumentException("Invalid scrolling value provided!");
}

if ($this->scrolling !== $scrolling) {
$this->scrolling = $scrolling;
$this->setChanged(true);
}
return $this;
}

######################################################################
# rendering #
######################################################################
Expand All @@ -279,6 +339,7 @@ protected function renderAttributes(): string
. Util::renderHtmlAttribute('srcdoc', $this->srcdoc)
. Util::renderHtmlAttribute('name', $this->name)
. Util::renderHtmlAttribute('sandbox', ($this->sandbox && \count($this->sandboxFeatures) > 0 ? $this->sandboxFeatures : $this->sandbox))
. Util::renderHtmlAttribute('scrolling', $this->scrolling)
;
}
}
1 change: 1 addition & 0 deletions tests/Html/IframeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected function factory() : HtmlElement
"name" => ["foo", "bar"],
"width" => [20, 10],
"height" => [10, 20],
"scrolling" => [Iframe::SCROLLING_AUTO, Iframe::SCROLLING_YES, Iframe::SCROLLING_NO],
];

/**
Expand Down

0 comments on commit 8a05b48

Please sign in to comment.