Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/document event #380

Merged
merged 4 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions bridge/bindings/jsc/DOM/document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ DocumentInstance::DocumentInstance(JSDocument *document)
JSStringRef tagName = JSStringCreateWithUTF8CString("HTML");
documentElement = new ElementInstance(JSElement::instance(document->context), tagName, HTML_TARGET_ID);
documentElement->m_document = this;
documentElement->parentNode = this;
JSStringHolder documentElementStringHolder = JSStringHolder(context, "documentElement");
JSObjectSetProperty(ctx, object, documentElementStringHolder.getString(),
documentElement->object, kJSPropertyAttributeReadOnly, nullptr);
Expand Down
6 changes: 6 additions & 0 deletions integration_tests/specs/dom/elements/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ describe('html', () => {
it('tagName is HTML', async () => {
expect(document.documentElement.tagName).toBe('HTML');
});

it('parentNode is document', async () => {
expect(document.documentElement.parentNode).toBe(document);
});


});
28 changes: 28 additions & 0 deletions integration_tests/specs/dom/events/mouseEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,32 @@ describe('MouseEvent', () => {

span.click();
});

it('should work width document addEventListener', async (done) => {
const div = document.createElement('div');
div.style.backgroundColor = 'red';
div.style.width = '100px';
div.style.height = '100px';
document.body.appendChild(div);

document.addEventListener('click', function handler(e) {
done();
});

await simulateClick(10.0, 10.0);
});

it('should work width body addEventListener', async (done) => {
const div = document.createElement('div');
div.style.backgroundColor = 'red';
div.style.width = '100px';
div.style.height = '100px';
document.body.appendChild(div);

document.body.addEventListener('click', function handler(e) {
done();
});

await simulateClick(10.0, 10.0);
});
});