Browse Source
Merge pull request #3201 from longdoan7421/fix/toJSON-ComponentImage
Fix bug `src` is stored twice in JSON stringification of ComponentImage. Closes #2913
pull/3217/head
Artur Arseniev
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
19 additions and
0 deletions
-
src/dom_components/model/ComponentImage.js
-
test/specs/dom_components/model/ComponentImage.js
|
|
|
@ -95,6 +95,21 @@ export default Component.extend( |
|
|
|
return this.get('src') === result(this, 'defaults').src; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* Return a shallow copy of the model's attributes for JSON |
|
|
|
* stringification. |
|
|
|
* @return {Object} |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
toJSON(...args) { |
|
|
|
const obj = Component.prototype.toJSON.apply(this, args); |
|
|
|
if (obj.src === obj.attributes.src) { |
|
|
|
delete obj.src; |
|
|
|
} |
|
|
|
|
|
|
|
return obj; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* Parse uri |
|
|
|
* @param {string} uri |
|
|
|
|
|
|
|
@ -8,6 +8,10 @@ describe('ComponentImage', () => { |
|
|
|
componentImage = new ComponentImage(); |
|
|
|
}); |
|
|
|
|
|
|
|
test('`src` property is defined after initializing', () => { |
|
|
|
expect(componentImage.get('src')).toBeDefined(); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('.getAttrToHTML', () => { |
|
|
|
let getSrcResultSpy; |
|
|
|
const fakeAttributes = {}; |
|
|
|
|