diff --git a/src/Html/Iframe.php b/src/Html/Iframe.php index 7e90922..438b547 100644 --- a/src/Html/Iframe.php +++ b/src/Html/Iframe.php @@ -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 # ###################################################################### @@ -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) ; } } diff --git a/tests/Html/IframeTest.php b/tests/Html/IframeTest.php index 8fce158..d13f43b 100644 --- a/tests/Html/IframeTest.php +++ b/tests/Html/IframeTest.php @@ -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], ]; /**