1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00
ferret/pkg/drivers/cdp/templates/set_inner_html.go
Tim Voronov 6ec50c5e43
Bugfix/inner text html by selector (#347)
* Fixed inner text

* Fixed inner html

* Updated set inner html and inner text

* Changed mechanism of reading and writing inner text and html

* updated makefile

* Added e2e tests

* Updated makefile

* Updated changelog

* Reverted dynamic page example
2019-08-05 19:57:02 -04:00

35 lines
558 B
Go

package templates
import (
"fmt"
"github.com/MontFerret/ferret/pkg/drivers"
)
const setInnerHTMLTemplate = `
(element, value) => {
element.innerHTML = value;
}
`
func SetInnerHTML() string {
return setInnerHTMLTemplate
}
var setInnerHTMLBySelectorTemplate = fmt.Sprintf(`
(el, selector, value) => {
const found = el.querySelector(selector);
if (found == null) {
throw new Error('%s');
}
found.innerHTML = value;
}
`,
drivers.ErrNotFound,
)
func SetInnerHTMLBySelector() string {
return setInnerHTMLBySelectorTemplate
}