PHP-CSS-Parser icon indicating copy to clipboard operation
PHP-CSS-Parser copied to clipboard

Support for inserting an item in a CSSList

Open FMCorz opened this issue 8 years ago • 1 comments

For your consideration.

FMCorz avatar Aug 01 '16 11:08 FMCorz

I like the idea, but the method name insert suggests that it must have a parameter for position: before or after. Also what if we just map this to the existing replace? Suggestion:

	public function insert($oItem, $oSibling, $sPosition = 'before') {
		$iIndex = array_search($oSibling, $this->aContents);
		if ($iIndex === false) {
			return $this->append($oItem);
		} else if ($sPosition === 'before') {
			$this->replace($oItem, array($oSibling, $oItem));
		} else {
			$this->replace($oItem, array($oItem, $oSibling));
		}
	}

raxbg avatar Nov 13 '19 09:11 raxbg

As there was no progress on this for the last five years I created #545.

ziegenberg avatar Jun 17 '24 09:06 ziegenberg

@oliverklee I think this can now be closed.

ziegenberg avatar Jun 20 '24 09:06 ziegenberg

Indeed it can. Thanks for implementing/finishing this, @ziegenberg! :heart:

Implemented in #545.

oliverklee avatar Jun 20 '24 09:06 oliverklee