为什么 MutationObserver 不适用于 FullCalendar 中的标题更改?

Why MutationObserver does not work for title change in FullCalendar?

我需要知道 FullCalendar 的当前标题。单击导航按钮后可以更改标题。

我没有找到任何 FullCalendar 本机方法来获取标题,所以我正在寻找其他方法来找出答案。我认为 MutationObserver 会起作用。但是当通过按钮更改文本时它不起作用。如果通过 JavaScript

完成更改
 var Calendar = FullCalendar.Calendar;
 var calendarEl = document.getElementById('calendar');
 
 calendar = new Calendar(calendarEl, {
         
 })
   
 calendar.render()
   
 //More Details https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
 // select the target node
//var target = document.getElementsByClassName('ffc-toolbar-title')[0]
var target = document.getElementsByClassName('fc-toolbar-title')[0]
//var target = document.getElementById('1')
  console.log(target.innerText);  


// create an observer instance
//var observer = new WebKitMutationObserver(function(mutations) {
var observer = new MutationObserver(function(mutations) {
  console.log(target.innerText);   
  console.log("comming from obeserver")
});
// configuration of the observer:
var config = { attributes: true, childList: true, characterData: true };
// pass in the target node, as well as the observer options
observer.observe(target, config);

setInterval(function(){
  //  target.innerText = ('hello world ' + Math.random() + '!!!');
},1000); 

然后 MutationObserver 工作。

知道如何解决这个问题吗?工作 jsFiddle

通过将 subtree: true 添加到 config,我能够观察到点击月份 increment/decrement 按钮所产生的变化。

来自MDN's page on "MutationObserver.characterData"

Note that this doesn't monitor content of an HTMLElement, even if it only contains text inside, as it only monitors text nodes themselves. So either pass directly a text node to the observe() method or you need to also set subtree: true.