Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Workaround for Ember Data hasDirtyAttributes strict equality
/* This is a silly workaround for this */
import Ember from 'ember';
import DS from 'ember-data';
import _values from 'lodash/object/values';
const { computed } = Ember;
export function checkIsActuallyDirty(diff) {
const [val1, val2] = diff;
// intentional double equal comparison
if (val1 == val2) { /* jshint ignore:line */
return false;
export function initialize() {
isActuallyDirty: computed('hasDirtyAttributes', function() {
let isActuallyDirty = false;
if (this.get('hasDirtyAttributes')) {
const changedAttrs = _values(this.changedAttributes());
isActuallyDirty = changedAttrs.any(function(diff) {
return checkIsActuallyDirty(diff);
return isActuallyDirty;
export default {
name: 'ember-data-is-actually-dirty',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.