Browse Source

Remove `src` prop in JSON stringification of ComponentImage

pull/3201/head
longdoan7421 5 years ago
parent
commit
3ee5622957
  1. 15
      src/dom_components/model/ComponentImage.js
  2. 4
      test/specs/dom_components/model/ComponentImage.js

15
src/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

4
test/specs/dom_components/model/ComponentImage.js

@ -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 = {};

Loading…
Cancel
Save