@@ -81,6 +81,7 @@ var replaceFromUrl = function(context,url){
81
81
return ;
82
82
}
83
83
84
+ // first pass imports foreign symbols and builds the idmap
84
85
var idmap = { } ;
85
86
for ( var i = 0 ; i < imports . length ; ++ i ) {
86
87
var obj = imports [ i ] ;
@@ -92,17 +93,29 @@ var replaceFromUrl = function(context,url){
92
93
var localID = String ( obj . localSymbol . symbolID ( ) ) ;
93
94
var foreignID = String ( importedSymbol . symbolMaster ( ) . symbolID ( ) ) ;
94
95
idmap [ localID ] = foreignID ;
96
+ }
95
97
96
- // replace all local instances with the newly imported symbol
98
+ for ( var i = 0 ; i < imports . length ; ++ i ) {
99
+ var obj = imports [ i ] ;
100
+ // replace all local instances with the newly imported symbol, taking care to update
101
+ // the overrides first
97
102
for ( var j = 0 ; j < obj . localInstances . length ; ++ j ) {
98
- obj . localInstances [ j ] . changeInstanceToSymbol ( importedSymbol . symbolMaster ( ) ) ;
103
+ if ( ! MSLayerPaster . updateOverridesOnInstance_withIDMap_ ) {
104
+ obj . localInstances [ j ] . updateOverridesWithObjectIDMap ( idmap ) ;
105
+ } else {
106
+ MSLayerPaster . updateOverridesOnInstance_withIDMap_ ( obj . localInstances [ j ] , idmap ) ;
107
+ }
99
108
}
100
109
}
101
110
102
- // ensure there are no dangling overrides still pointing to local symbols
111
+ // finally, ensure there are no dangling overrides in instances we haven't replaced
103
112
var allInstances = getAllInstances ( context . document ) ;
104
113
for ( var i = 0 ; i < allInstances . length ; ++ i ) {
105
- MSLayerPaster . updateOverridesOnInstance_withIDMap_ ( allInstances [ i ] , idmap ) ;
114
+ if ( ! MSLayerPaster . updateOverridesOnInstance_withIDMap_ ) {
115
+ allInstances [ i ] . updateOverridesWithObjectIDMap ( idmap ) ;
116
+ } else {
117
+ MSLayerPaster . updateOverridesOnInstance_withIDMap_ ( allInstances [ i ] , idmap ) ;
118
+ }
106
119
}
107
120
108
121
var decision = yesNoDialog ( 'Cool! All done.\n\nDo you want to delete the ' +
0 commit comments