mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-29 02:50:10 +00:00
minor fixes, getting ready for refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2e6591e03e
commit
c7ca8ee53e
@ -340,6 +340,7 @@ ExtendedDiff.types.delete('Text')
|
|||||||
|
|
||||||
The [source code](./diff.js#L1098) is a good example for this as the base `Diff(..)` is built using this API, but note that we are registering types on the `Types` object rather than on the `Diff` itself, there is no functional difference other than how the main code is structured internally.
|
The [source code](./diff.js#L1098) is a good example for this as the base `Diff(..)` is built using this API, but note that we are registering types on the `Types` object rather than on the `Diff` itself, there is no functional difference other than how the main code is structured internally.
|
||||||
|
|
||||||
|
*XXX handler context may change in the near future*
|
||||||
The handler methods are all called in the context of the `Diff.types` object.
|
The handler methods are all called in the context of the `Diff.types` object.
|
||||||
|
|
||||||
To call a different type handler's methods use:
|
To call a different type handler's methods use:
|
||||||
|
|||||||
13
diff.js
13
diff.js
@ -1498,6 +1498,15 @@ Types.set('Text', {
|
|||||||
// stage to apply the results...
|
// stage to apply the results...
|
||||||
// XXX add object compatibility checks...
|
// XXX add object compatibility checks...
|
||||||
patch: function(obj, key, change){
|
patch: function(obj, key, change){
|
||||||
|
/* XXX this needs to be in the context of the diff/pathc instance...
|
||||||
|
var cache = this._text_cache = this._text_cache || {}
|
||||||
|
var lines = cache[obj] || obj.split(/\n/)
|
||||||
|
|
||||||
|
var res = cache[obj] = this.typeCall(Array, 'patch', lines, key, change)
|
||||||
|
|
||||||
|
// XXX do this on the finalize stage...
|
||||||
|
return res.join('\n')
|
||||||
|
//*/
|
||||||
return this.typeCall(Array, 'patch', obj.split(/\n/), key, change)
|
return this.typeCall(Array, 'patch', obj.split(/\n/), key, change)
|
||||||
.join('\n')
|
.join('\n')
|
||||||
},
|
},
|
||||||
@ -1654,6 +1663,10 @@ var DiffClassPrototype = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX need to make the diff object the universal context...
|
||||||
|
// ...currently the context for most things is .constructor.types
|
||||||
|
// which is global this anything that any handler does is not local
|
||||||
|
// to a particular diff instance...
|
||||||
var DiffPrototype = {
|
var DiffPrototype = {
|
||||||
// system meta information...
|
// system meta information...
|
||||||
get format(){
|
get format(){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user