diff --git a/demo/src/app.ts b/demo/src/app.ts
index 16c53a5f..293713f1 100644
--- a/demo/src/app.ts
+++ b/demo/src/app.ts
@@ -54,7 +54,7 @@ const run = () => {
worker.postMessage({'sentence': outputContainerElement.textContent, 'model': model});
const parser = parsers.get(model);
if (!parser) return;
- parser.applyElement(outputContainerElement);
+ parser.applyToElement(outputContainerElement);
outputContainerElement.style.fontSize = `${fontSizeElement.value}rem`;
const renderWithBR = brCheckElement.checked;
if (renderWithBR) {
diff --git a/javascript/README.md b/javascript/README.md
index 4264d3b7..87144a5c 100644
--- a/javascript/README.md
+++ b/javascript/README.md
@@ -67,12 +67,12 @@ You can also feed an HTML element to the parser to apply the process.
const ele = document.querySelector('p.budou-this');
console.log(ele.outerHTML);
//
今日はとても天気です。
-parser.applyElement(ele);
+parser.applyToElement(ele);
console.log(ele.outerHTML);
// 今日はとても天気です。
```
-Internally, the `applyElement` calls the [`HTMLProcessor`] class
+Internally, the `applyToElement` calls the [`HTMLProcessor`] class
with a `` element as the separator.
You can use the [`HTMLProcessor`] class directly if desired.
For example:
diff --git a/javascript/src/html_processor.ts b/javascript/src/html_processor.ts
index 289341da..b990a648 100644
--- a/javascript/src/html_processor.ts
+++ b/javascript/src/html_processor.ts
@@ -603,10 +603,25 @@ export class HTMLProcessingParser extends Parser {
}
/**
+ * @deprecated Use `applyToElement` instead. `applyElement` will be removed
+ * in v0.7.0 to align the function name with `HTMLProcessor`'s API.
+ *
* Applies markups for semantic line breaks to the given HTML element.
* @param parentElement The input element.
*/
applyElement(parentElement: HTMLElement) {
+ console.warn(
+ '`applyElement` is deprecated. Please use `applyToElement` instead. ' +
+ '`applyElement` will be removed in v0.7.0.'
+ );
+ this.applyToElement(parentElement);
+ }
+
+ /**
+ * Applies markups for semantic line breaks to the given HTML element.
+ * @param parentElement The input element.
+ */
+ applyToElement(parentElement: HTMLElement) {
this.htmlProcessor.applyToElement(parentElement);
}
@@ -624,7 +639,7 @@ export class HTMLProcessingParser extends Parser {
wrapper.append(...doc.body.childNodes);
doc.body.append(wrapper);
}
- this.applyElement(doc.body.childNodes[0] as HTMLElement);
+ this.applyToElement(doc.body.childNodes[0] as HTMLElement);
return doc.body.innerHTML;
}
}
diff --git a/javascript/src/tests/test_html_processor.ts b/javascript/src/tests/test_html_processor.ts
index 78302c4e..e2464a23 100644
--- a/javascript/src/tests/test_html_processor.ts
+++ b/javascript/src/tests/test_html_processor.ts
@@ -316,7 +316,7 @@ describe('HTMLProcessor.splitNodes', () => {
});
});
-describe('HTMLProcessingParser.applyElement', () => {
+describe('HTMLProcessingParser.applyToElement', () => {
const checkEqual = (
model: {[key: string]: {[key: string]: number}},
inputHTML: string,
@@ -325,7 +325,7 @@ describe('HTMLProcessingParser.applyElement', () => {
const inputDOM = parseFromString(inputHTML);
const inputDocument = inputDOM.querySelector('p') as HTMLElement;
const parser = new HTMLProcessingParser(model);
- parser.applyElement(inputDocument);
+ parser.applyToElement(inputDocument);
const expectedDocument = parseFromString(expectedHTML);
const expectedElement = expectedDocument.querySelector('p') as HTMLElement;
expect(inputDocument.isEqualNode(expectedElement)).toBeTrue();
diff --git a/javascript/src/tests/test_webcomponents.ts b/javascript/src/tests/test_webcomponents.ts
index 8177f8d0..1b81a218 100644
--- a/javascript/src/tests/test_webcomponents.ts
+++ b/javascript/src/tests/test_webcomponents.ts
@@ -33,7 +33,7 @@ describe('Web Components', () => {
const mirroredElement = window.document.createElement('span');
mirroredElement.textContent = inputText;
- parser.applyElement(mirroredElement);
+ parser.applyToElement(mirroredElement);
expect(budouxElement.innerHTML).toBe(mirroredElement.outerHTML);
});
@@ -46,7 +46,7 @@ describe('Web Components', () => {
const inputText = '明日はどうなるかな。';
const mirroredElement = window.document.createElement('span');
mirroredElement.textContent = inputText;
- parser.applyElement(mirroredElement);
+ parser.applyToElement(mirroredElement);
const observer = new window.MutationObserver(() => {
expect(budouxElement.innerHTML).toBe(mirroredElement.outerHTML);