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

Add inherited properties test #2263

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Conversation

justinfagnani
Copy link
Contributor

This adds a test of setting inherited properties - properties that are defined by accessors on a super class of the element class. Libraries can fail this check if the use a heuristic to decide when to set properties and that heuristic is only checking for own properties of the direct prototype of the element instance.

In reviewing this it's important to check that the each new test is correct:

  • The new library component is using the <ce-with-inheritance> element
  • The <ce-with-inheritance> defining module is imported
  • The test is using the new library component
  • The expectations are correctly copied from the other property tests

@github-actions
Copy link
Contributor

Copy link

@augustjk augustjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a problem with angularjs, making my way through the rest.

@@ -81,6 +81,34 @@ const ComponentWithProps = {
}
};

const ComponentWithInheritance = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about angularjs but looking at what's already here, i think the component needs to be added here:

import 'angular';
import {
ComponentWithoutChildren,
ComponentWithChildren,
ComponentWithChildrenRerender,
ComponentWithDifferentViews,
ComponentWithProps,
ComponentWithImperativeEvent,
ComponentWithDeclarativeEvent
} from './components';
export default angular.module('ce-tests', [])
.component('compNoChildren', ComponentWithoutChildren)
.component('compWithChildren', ComponentWithChildren)
.component('compWithChildrenRerender', ComponentWithChildrenRerender)
.component('compWithDifferentViews', ComponentWithDifferentViews)
.component('compWithProps', ComponentWithProps)
.component('compWithImperativeEvent', ComponentWithImperativeEvent)
.component('compWithDeclarativeEvent', ComponentWithDeclarativeEvent)
.name;

needs to import ComponentWithInheritance declared here, and needs

.component('compWithInheritance', ComponentWithInheritance)

and the top of this file also has import lines, which probably needs this added

import 'ce-with-inheritance';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.... it's working w/o that, but I'm not sure what that means.

let fixture = TestBed.createComponent(ComponentWithInheritance);
fixture.detectChanges();
let root = fixture.debugElement.nativeElement;
let wc = root.querySelector("#wc");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check bools, nums, and strings? Or do you want to do that in a basic test? Follow up PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow up PR?

Copy link

@augustjk augustjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More missing import 'ce-with-inheritance';

libraries/svelte/src/components.js Show resolved Hide resolved
libraries/dio/src/components.js Show resolved Hide resolved
libraries/dojo/src/components.ts Show resolved Hide resolved
libraries/hybrids/src/components.js Show resolved Hide resolved
libraries/hyperapp/src/components.js Show resolved Hide resolved
libraries/hyperhtml/src/components.js Show resolved Hide resolved
@justinfagnani
Copy link
Contributor Author

Thanks @augustjk !

With the imports fixed, I don't think this shows any interesting failures. I think the new ones are from camelCase properties, so I'm going to remove that check to isolate only inheritance.

I was thrown off with a report of a different bug near this Svelte code: https://github.com/sveltejs/svelte/blob/6f508a011bc8051ab9f82cafa97c5292a4453b92/packages/svelte/src/runtime/internal/dom.js#L437

That looks like it's only looking at own properties before making an attribute/property decision, but it turns out there's a switch before that on elements with a - in the name that goes to an in-check: https://github.com/sveltejs/svelte/blob/6f508a011bc8051ab9f82cafa97c5292a4453b92/packages/svelte/src/runtime/internal/dom.js#L483

I still think this is a decent test to have, since it's conceivable a library could have faulty logic here. At worst it bumps most libraries scores a bit with another passing test.

Copy link

@augustjk augustjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call on isolating out the camelCase props for the inheritance test.

@ekashida ekashida mentioned this pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants