Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
fcaa9bbe
Commit
fcaa9bbe
authored
May 26, 2023
by
Gabriel Ivăncescu
Committed by
Alexandre Julliard
May 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: Implement classList's toggle() method.
Signed-off-by:
Gabriel Ivăncescu
<
gabrielopcode@gmail.com
>
parent
59f7fbee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
12 deletions
+67
-12
htmlelem.c
dlls/mshtml/htmlelem.c
+12
-11
dom.js
dlls/mshtml/tests/dom.js
+55
-1
No files found.
dlls/mshtml/htmlelem.c
View file @
fcaa9bbe
...
...
@@ -7464,7 +7464,7 @@ static const WCHAR *find_token(const WCHAR *list, const WCHAR *token, unsigned i
return
NULL
;
}
static
HRESULT
token_list_add_remove
(
IWineDOMTokenList
*
iface
,
BSTR
token
,
BOOL
remove
)
static
HRESULT
token_list_add_remove
(
IWineDOMTokenList
*
iface
,
BSTR
token
,
BOOL
remove
,
VARIANT_BOOL
*
toggle_ret
)
{
struct
token_list
*
token_list
=
impl_from_IWineDOMTokenList
(
iface
);
unsigned
int
i
,
len
,
old_len
,
new_len
;
...
...
@@ -7472,7 +7472,7 @@ static HRESULT token_list_add_remove(IWineDOMTokenList *iface, BSTR token, BOOL
BSTR
new
,
old
;
HRESULT
hr
;
TRACE
(
"
iface %p, token %s, remove %#x.
\n
"
,
iface
,
debugstr_w
(
token
),
remove
);
TRACE
(
"
token_list %p, token %s, remove %#x, toggle_ret %p.
\n
"
,
token_list
,
debugstr_w
(
token
),
remove
,
toggle_ret
);
len
=
token
?
lstrlenW
(
token
)
:
0
;
if
(
!
len
)
...
...
@@ -7493,8 +7493,13 @@ static HRESULT token_list_add_remove(IWineDOMTokenList *iface, BSTR token, BOOL
TRACE
(
"old %s.
\n
"
,
debugstr_w
(
old
));
if
(((
old_pos
=
find_token
(
old
,
token
,
len
))
&&
!
remove
)
||
(
!
old_pos
&&
remove
))
old_pos
=
find_token
(
old
,
token
,
len
);
if
(
toggle_ret
)
{
remove
=
!!
old_pos
;
*
toggle_ret
=
!
remove
;
}
else
if
(
!!
old_pos
!=
remove
)
{
SysFreeString
(
old
);
return
S_OK
;
...
...
@@ -7553,21 +7558,17 @@ static HRESULT token_list_add_remove(IWineDOMTokenList *iface, BSTR token, BOOL
static
HRESULT
WINAPI
token_list_add
(
IWineDOMTokenList
*
iface
,
BSTR
token
)
{
return
token_list_add_remove
(
iface
,
token
,
FALSE
);
return
token_list_add_remove
(
iface
,
token
,
FALSE
,
NULL
);
}
static
HRESULT
WINAPI
token_list_remove
(
IWineDOMTokenList
*
iface
,
BSTR
token
)
{
return
token_list_add_remove
(
iface
,
token
,
TRUE
);
return
token_list_add_remove
(
iface
,
token
,
TRUE
,
NULL
);
}
static
HRESULT
WINAPI
token_list_toggle
(
IWineDOMTokenList
*
iface
,
BSTR
token
,
VARIANT_BOOL
*
p
)
{
struct
token_list
*
token_list
=
impl_from_IWineDOMTokenList
(
iface
);
FIXME
(
"(%p)->(%s %p)
\n
"
,
token_list
,
debugstr_w
(
token
),
p
);
return
E_NOTIMPL
;
return
token_list_add_remove
(
iface
,
token
,
FALSE
,
p
);
}
static
HRESULT
WINAPI
token_list_contains
(
IWineDOMTokenList
*
iface
,
BSTR
token
,
VARIANT_BOOL
*
p
)
...
...
dlls/mshtml/tests/dom.js
View file @
fcaa9bbe
...
...
@@ -623,7 +623,7 @@ sync_test("hasAttribute", function() {
sync_test
(
"classList"
,
function
()
{
var
elem
=
document
.
createElement
(
"div"
);
var
classList
=
elem
.
classList
,
i
;
var
classList
=
elem
.
classList
,
i
,
r
;
var
props
=
[
"add"
,
"contains"
,
"item"
,
"length"
,
"remove"
,
"toggle"
];
for
(
i
=
0
;
i
<
props
.
length
;
i
++
)
...
...
@@ -765,6 +765,60 @@ sync_test("classList", function() {
classList
.
remove
(
"b"
);
ok
(
elem
.
className
===
""
,
"remove: expected className '', got "
+
elem
.
className
);
exception
=
false
;
try
{
classList
.
toggle
();
}
catch
(
e
)
{
exception
=
true
;
}
ok
(
exception
,
"Expected exception for classList.toggle()"
);
exception
=
false
;
try
{
classList
.
toggle
(
""
);
}
catch
(
e
)
{
exception
=
true
;
}
ok
(
exception
,
"Expected exception for classList.toggle(
\"\"
)"
);
exception
=
false
;
try
{
classList
.
toggle
(
"a b"
);
}
catch
(
e
)
{
exception
=
true
;
}
ok
(
exception
,
"Expected exception for classList.toggle(
\"
a b
\"
)"
);
// toggle's second arg is not implemented by IE, and ignored
r
=
classList
.
toggle
(
"abc"
);
ok
(
r
===
true
,
"toggle('abc') returned "
+
r
);
ok
(
elem
.
className
===
"abc"
,
"toggle('abc'): got className "
+
elem
.
className
);
r
=
classList
.
toggle
(
"def"
,
false
);
ok
(
r
===
true
,
"toggle('def', false) returned "
+
r
);
ok
(
elem
.
className
===
"abc def"
,
"toggle('def', false): got className "
+
elem
.
className
);
r
=
classList
.
toggle
(
"123"
,
1234
);
ok
(
r
===
true
,
"toggle('123', 1234) returned "
+
r
);
ok
(
elem
.
className
===
"abc def 123"
,
"toggle('123', 1234): got className "
+
elem
.
className
);
r
=
classList
.
toggle
(
"def"
,
true
);
ok
(
r
===
false
,
"toggle('def', true) returned "
+
r
);
ok
(
elem
.
className
===
"abc 123"
,
"toggle('def', true): got className "
+
elem
.
className
);
r
=
classList
.
toggle
(
"123"
,
null
);
ok
(
r
===
false
,
"toggle('123', null) returned "
+
r
);
ok
(
elem
.
className
===
"abc"
,
"toggle('123', null): got className "
+
elem
.
className
);
elem
.
className
=
" testclass foobar "
;
ok
((
""
+
classList
)
===
" testclass foobar "
,
"Expected classList value ' testclass foobar ', got "
+
classList
);
ok
(
classList
.
toString
()
===
" testclass foobar "
,
"Expected classList toString ' testclass foobar ', got "
+
classList
.
toString
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment