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 issues related to equals method defined on RDF term instances #1200

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

elpoelma
Copy link
Contributor

@elpoelma elpoelma commented Jun 17, 2024

Overview

This PR includes some changes in how the equals method/property is defined on RDF term instances.
It defines equals as a prototype method on RDF term instances instead of as arrow functions.
This has two implications:

  • The equals function is no longer defined on RDF term instances themselves, but rather on their prototype.
  • Comparison functions (such as the one used by prosemirror-devtools) no longer fail due to them not supporting function properties.
  • Spreading an RDF term results in losing the equals method.
connected issues and PRs:

None

How to test/reproduce

  • Open up the dummy app
  • Insert a sample document containing RDFa
  • Ensure that functions are not supported error message no longer shows up.
  • There should be no issues with missing/undefined equals properties.

Challenges/uncertainties

The change/rollback included in this PR does have some (possibly unwanted) side-effects:

  • As mentioned before , applying the spread operator on an RDF term instances results in losing the equals method. Typescript tries to handle this in the best way possible, but may sometimes make mistakes. An example can be found on Typescript playground

Other possible approaches:

  • Using simple data objects to represent the RDF terms and using separately defined equals functions. This does have the drawback that we cannot leverage the RDFJS interfaces.
  • Ensuring that the comparison library used by the prosemirror devtools adds support for function properties. This can be a long-term solution which is possibly the best approach, as it may occur in other situations that prosemirror node-attributes contain arrow function properties. See Ignore functions instead of throwing error? benjamine/jsondiffpatch#284 for more info

Checks PR readiness

  • UI: works on smaller screen sizes
  • UI: feedback for any loading/error states
  • Check cancel/go-back flows
  • Check database state correct when deleting/updating (especially regarding relationships)
  • changelog
  • npm lint
  • no new deprecations

@elpoelma elpoelma added the bug Something isn't working label Jun 17, 2024
@elpoelma elpoelma self-assigned this Jun 17, 2024
Copy link
Contributor

@lagartoverde lagartoverde left a comment

Choose a reason for hiding this comment

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

Looks good, maybe you should wait for another review that knows about the implications of this change (cough cough Arne) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants