@@ -3,6 +3,7 @@ import "regenerator-runtime/runtime"; // needed for ``await`` support
3
3
import $ from "jquery" ;
4
4
import _ from "underscore" ;
5
5
import ajax from "../ajax/ajax" ;
6
+ import dom from "../../core/dom" ;
6
7
import logging from "../../core/logging" ;
7
8
import Parser from "../../core/parser" ;
8
9
import registry from "../../core/registry" ;
@@ -867,6 +868,14 @@ const inject = {
867
868
VIDEO : "data-pat-inject-rebase-src" ,
868
869
} ,
869
870
871
+ _rebaseOptions : {
872
+ "data-pat-inject" : [ "url" ] ,
873
+ "data-pat-calendar" : [ "url" ] ,
874
+ "data-pat-date-picker" : [ "i18n" ] ,
875
+ "data-pat-datetime-picker" : [ "i18n" ] ,
876
+ "data-pat-collapsible" : [ "load-content" ] ,
877
+ } ,
878
+
870
879
_rebaseHTML ( base , html ) {
871
880
if ( html === "" ) {
872
881
// Special case, source is none
@@ -901,6 +910,29 @@ const inject = {
901
910
$el_ . attr ( attrName , value ) ;
902
911
}
903
912
} ) ;
913
+
914
+ for ( const [ attr , opts ] of Object . entries ( this . _rebaseOptions ) ) {
915
+ for ( const el_ of dom . querySelectorAllAndMe (
916
+ $page [ 0 ] ,
917
+ `[${ attr } ]`
918
+ ) ) {
919
+ const val = el_ . getAttribute ( attr , false ) ;
920
+ if ( val ) {
921
+ let options = parser . _parse ( val ) ;
922
+ let changed = false ;
923
+ for ( const opt of opts ) {
924
+ if ( options [ opt ] ) {
925
+ options [ opt ] = utils . rebaseURL ( base , options [ opt ] ) ;
926
+ changed = true ;
927
+ }
928
+ }
929
+ if ( changed ) {
930
+ el_ . setAttribute ( attr , JSON . stringify ( options ) ) ;
931
+ }
932
+ }
933
+ }
934
+ }
935
+
904
936
// XXX: IE8 changes the order of attributes in html. The following
905
937
// lines move data-pat-inject-rebase-src to src.
906
938
$page . find ( "[data-pat-inject-rebase-src]" ) . each ( ( id , el_ ) => {
0 commit comments