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:
@ -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)
|
||||
|
Reference in New Issue
Block a user