1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-05 00:49:00 +02:00

Added support of computed styles (#570)

* Added support of computed styles

* Updated style updates

* Fixed linter issues

* Updated styles manipulation in static driver

* Updated e2e tests

* Updated methods

* Updated e2e tests

* Updated README
This commit is contained in:
Tim Voronov
2020-11-20 20:09:21 -05:00
committed by GitHub
parent 01088247e2
commit 7eed93721c
26 changed files with 200 additions and 125 deletions

View File

@ -2,6 +2,7 @@ package html
import (
"context"
"github.com/MontFerret/ferret/pkg/drivers/common"
"github.com/MontFerret/ferret/pkg/drivers"
"github.com/MontFerret/ferret/pkg/runtime/core"
@ -35,13 +36,18 @@ func AttributeSet(ctx context.Context, args ...core.Value) (core.Value, error) {
return values.None, nil
}
arg2, ok := args[2].(values.String)
switch arg2 := args[2].(type) {
case values.String:
return values.None, el.SetAttribute(ctx, arg1, arg2)
case *values.Object:
if arg1 == common.AttrNameStyle {
return values.None, el.SetAttribute(ctx, arg1, common.SerializeStyles(ctx, arg2))
}
if !ok {
return values.None, el.SetAttribute(ctx, arg1, values.NewString(arg2.String()))
default:
return values.None, core.TypeError(arg1.Type(), types.String, types.Object)
}
return values.None, el.SetAttribute(ctx, arg1, arg2)
case *values.Object:
// ATTR_SET(el, values)
return values.None, el.SetAttributes(ctx, arg1)