Skip to content

Commit 4dcc0d8

Browse files
authored
Merge pull request #13940 from k-chop/backport-to-6-ismodified-acccept-string-of-keys
Backport document.isModified fix #13674 to 6.x
2 parents 917f2ff + 0ae97d1 commit 4dcc0d8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,7 @@ Document.prototype.isModified = function(paths, modifiedPaths) {
22272227
}
22282228

22292229
if (typeof paths === 'string') {
2230-
paths = [paths];
2230+
paths = paths.indexOf(' ') === -1 ? [paths] : paths.split(' ');
22312231
}
22322232

22332233
for (const path of paths) {

test/document.modified.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ describe('document modified', function() {
176176
assert.equal(post.isModified('title'), false);
177177
});
178178

179+
it('should support passing a string of keys separated by a blank space as the first argument', function() {
180+
const post = new BlogPost();
181+
post.init({
182+
title: 'Test',
183+
slug: 'test',
184+
date: new Date()
185+
});
186+
187+
assert.equal(post.isModified('title'), false);
188+
post.set('title', 'modified title');
189+
assert.equal(post.isModified('title'), true);
190+
assert.equal(post.isModified('slug'), false);
191+
assert.equal(post.isModified('title slug'), true);
192+
});
193+
194+
179195
describe('on DocumentArray', function() {
180196
it('work', function() {
181197
const post = new BlogPost();

0 commit comments

Comments
 (0)