Recently, I've been experimenting with a Mutation Observer and using the following configuration:
config = { characterData: true, characterDataOldValue: true };
This is the structure of my HTML page:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="script.js"></script>
<title>Test</title>
</head>
<body>
<p id="test" contenteditable="true">Test<b>subtree</b>test</p>
Interestingly, the Mutation observer wasn't functioning as expected until I included 'subtree' in the config:
config = { characterData: true, subtree: true, characterDataOldValue: true };
I'm a bit puzzled as to why this is necessary. Any explanations?