Skip to content

Instantly share code, notes, and snippets.

Created May 6, 2016 16:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save blimmer/cb7425d7bef06b5acb858e5f5f6a9e7a to your computer and use it in GitHub Desktop.
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