-
Notifications
You must be signed in to change notification settings - Fork 34
WIP: resolve property references to other namespace #39
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
Changes from all commits
8b726df
3500f89
c332a7e
3445726
1b5ce8c
7bdb05f
a4de9b3
1af0602
36aaacc
850e039
d9edaf2
15287f6
eb02138
96a9eab
073c3e9
e75cba8
d6f342b
596d002
7b0a6f5
66bb9e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| { | ||
| "name": "MultipleInheritance", | ||
| "uri": "http://multipleinheritance", | ||
| "prefix": "mh", | ||
| "types": [ | ||
| { | ||
| "name": "AnotherRoot", | ||
| "properties": [ | ||
| { | ||
| "name": "any", | ||
| "type": "AnotherRoot", | ||
| "isMany": true | ||
| }, | ||
| { | ||
| "name": "many", | ||
| "type": "String", | ||
| "isMany": true | ||
| }, | ||
| { | ||
| "name": "single", | ||
| "type": "String" | ||
| }, | ||
| { | ||
| "name": "defaultSingle", | ||
| "type": "String", | ||
| "default": "mh-default-string" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "MultipleInherited", | ||
| "superClass": [ "AnotherRoot", "props:Root", "dt:Root" ], | ||
| "properties": [ | ||
| { | ||
| "name": "anotherDefaultSingle", | ||
| "type": "Boolean", | ||
| "default": false | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "InvalidMultipleInherited", | ||
| "superClass": [ "AnotherRoot", "props:Root" ], | ||
| "properties": [ | ||
| { | ||
| "name": "defaultSingle", | ||
| "type": "Boolean", | ||
| "default": false | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -101,7 +101,10 @@ describe('moddle', function() { | |||||
|
|
||||||
| expect(descriptor.ns).to.jsonEqual(expectedDescriptorNs); | ||||||
| expect(descriptor.properties).to.jsonEqual(expectedDescriptorProperties); | ||||||
| expect(descriptor.propertiesByName).to.jsonEqual(expectedDescriptorPropertiesByName); | ||||||
| expect(descriptor.propertiesByName.id).to | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the original check here? I'd say we could add an additional test case, if we want:
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because I added a property and comparing the whole structure depends on the order. That's why I created two
👍 added I applied the suggestion and CI action failed (with an empty error message, why I missed to fix it immediately - and forgot to run tests again). Fixed it here. |
||||||
| .equal(descriptor.propertiesByName['props:id']); | ||||||
| expect(descriptor.propertiesByName['props:id']).to | ||||||
| .jsonEqual(expectedDescriptorPropertiesByName['props:id']); | ||||||
| }); | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting question here: What I'd expect is to have local name and ns name attribute present.
I.e. I can always access the value via
foo["a:id"]regardless if it has a local name set or not. On the other hand I'd like to havea#idalways available as the shorthand, if it is the onlyidproperty defined for an element.Likely this is only possible to accomplish via proxies, am I right about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are present, but ...
For
isMany-properties this is possible without a proxy, as we reference an object. But fundamental types (i.e.BUILTINS) are only accessible throughget()when referenced with theirlocalName.a#idon the other hand is always available througha.id(anda.get('id')of course), as long it was previously initialized (see my remarks below) - so yes, you're right.IMO this is a compromise that we should accept. As you say, the alternative would be the introduction of proxy objects.
I hope we understand each other (please don't hesitate to keep raising questions). The test cases should hold the truth to specify desired behaviour. So we need to make sure to get them right and fully cover this topic as well as update the documentation before merging.
Btw, the current implementation also fails to access
foo['a:id']if not initialized during creation or has a default value or was previously accessed withget(). I've not tested this out yet, but this seems to be the case for all properties exceptfoo.id. I.e. you need to useget()first beforefoo['a:id']is mapped into the object.This is somehow inconsistent and it might be a nice improvement to map property instances early (i.e. during type creation) even if they are not explicitly initialized or have a default value. I'd more like to get
undefinedinstead of an unexpected exception. If you like, I'll open another issue for this.One question in this context: should it be possible to define a default value for
isMany-properties (e.g."default": [ 1, 2 ])? I tried this, received no exception but the value was not applied. Maybe I miss it, but there seems to be no documentation or spec for this. Should I address this in a seperate issue or am I just wrong here?