mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 12:25:57 +08:00
fix: allow use of an attribute named relationships
This commit is contained in:
parent
53ac644516
commit
1ead69e9b6
@ -671,7 +671,7 @@ export default class Application {
|
||||
* @protected
|
||||
*/
|
||||
protected requestWasCrossOrigin(error: RequestError): boolean {
|
||||
return new URL(error.options.url, document.baseURI).origin !== window.location.origin;
|
||||
return new URL(error.options?.url, document.baseURI).origin !== window.location.origin;
|
||||
}
|
||||
|
||||
protected requestErrorDefaultHandler(e: unknown, isDebug: boolean, formattedErrors: string[]): void {
|
||||
|
@ -192,7 +192,8 @@ export default abstract class Model {
|
||||
// If a 'relationships' key exists, extract it from the attributes hash and
|
||||
// set it on the top-level data object instead. We will be sending this data
|
||||
// object to the API for persistence.
|
||||
if (attributes.relationships) {
|
||||
// But only if the model does not actually have a real relationships attribute.
|
||||
if (attributes.relationships && !('relationships' in this)) {
|
||||
data.relationships = {};
|
||||
|
||||
for (const key in attributes.relationships) {
|
||||
@ -208,6 +209,8 @@ export default abstract class Model {
|
||||
delete attributes.relationships;
|
||||
}
|
||||
|
||||
console.log('data', data);
|
||||
|
||||
// Before we update the model's data, we should make a copy of the model's
|
||||
// old data so that we can revert back to it if something goes awry during
|
||||
// persistence.
|
||||
|
Loading…
x
Reference in New Issue
Block a user