diff --git a/src/Selector/NamedSelector.php b/src/Selector/NamedSelector.php index c8a37bef8..94ce213f1 100644 --- a/src/Selector/NamedSelector.php +++ b/src/Selector/NamedSelector.php @@ -168,15 +168,28 @@ public function __construct() { $this->xpathEscaper = new Escaper(); - foreach ($this->replacements as $from => $to) { - $this->replacements[$from] = strtr($to, $this->replacements); - } + $this->replace(); + } - foreach ($this->selectors as $alias => $selector) { - $this->selectors[$alias] = strtr($selector, $this->replacements); - } + /** + * Replace placeholders with replacements + * + * @return NamedSelector + */ + public function replace() + { + foreach ($this->replacements as $from => $to) { + $this->replacements[$from] = strtr($to, $this->replacements); + } + + foreach ($this->selectors as $alias => $selector) { + $this->selectors[$alias] = strtr($selector, $this->replacements); + } + + return $this; } + /** * Registers new XPath selector with specified name. *