-
Notifications
You must be signed in to change notification settings - Fork 3
Implement .text property for HTMLScriptElement
#390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ceb2279
Initial plan
Copilot 9698751
Implement .text property for HTMLScriptElement
Copilot 243c1c2
Add spec references to .text property implementation
Copilot 11d6956
Implement dedicated .text getter for HTMLScriptElement with proper ch…
Copilot 6d321aa
Enhance HTMLScriptElement.text getter for improved text node handling…
EndlessJour9527 eff88a8
Enhance HTMLScriptElement.getText to include CDATA section nodes and …
EndlessJour9527 d030e82
Refactor HTMLScriptElement.getText to return textContent directly for…
6d15269
Refactor HTMLScriptElement text handling to use dedicated getter and …
EndlessJour9527 0cc2e07
Refactor HTMLScriptElement text handling methods for consistency and …
EndlessJour9527 d2762e2
Remove unnecessary include and rename test file to htmlscriptelement-…
Copilot 7704462
fix
yorkie 972492a
update
yorkie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Test HTMLScriptElement.text Getter/Setter</title> | ||
| <style> | ||
| body { font-family: sans-serif; } | ||
| .result-pass { color: green; } | ||
| .result-fail { color: red; } | ||
| .result { margin-bottom: 4px; } | ||
| pre { background: #f6f8fa; padding: 6px 10px; border-radius: 3px; } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <h2>Test <code>HTMLScriptElement.text</code> Getter/Setter</h2> | ||
| <div id="results"></div> | ||
| <pre id="details"></pre> | ||
| <script id="script1" type="text/javascript"> | ||
| // Hello from script1 | ||
| var x = 42; | ||
| </script> | ||
| <script> | ||
| function logResult(pass, message) { | ||
| const div = document.createElement('div'); | ||
| div.className = 'result ' + (pass ? 'result-pass' : 'result-fail'); | ||
| div.textContent = (pass ? "PASS: " : "FAIL: ") + message; | ||
| document.getElementById('results').appendChild(div); | ||
| console.log((pass ? "PASS: " : "FAIL: ") + message); | ||
| } | ||
| function appendDetails(text) { | ||
| document.getElementById('details').textContent += text + "\n"; | ||
| } | ||
|
|
||
| const s1 = document.getElementById('script1'); | ||
| appendDetails("Original .text: " + JSON.stringify(s1.text)); | ||
| appendDetails("Original .textContent: " + JSON.stringify(s1.textContent)); | ||
| logResult( | ||
| typeof s1.text === "string" && s1.text.includes('var x = 42;'), | ||
| "Getter: .text should contain script content" | ||
| ); | ||
|
|
||
| s1.text = "// Replaced!\nlet y = 99;"; | ||
| appendDetails("After set .text: " + JSON.stringify(s1.text)); | ||
| logResult( | ||
| s1.text === "// Replaced!\nlet y = 99;", | ||
| "Setter: .text should replace script content" | ||
| ); | ||
| logResult( | ||
| s1.textContent === s1.text, | ||
| ".textContent should equal .text after set" | ||
| ); | ||
|
|
||
| s1.text = ""; | ||
| appendDetails("After set .text to empty: " + JSON.stringify(s1.text)); | ||
| logResult( | ||
| s1.text === "", | ||
| "Setter: .text='' should clear script content" | ||
| ); | ||
| logResult( | ||
| s1.childNodes.length === 0, | ||
| "Setter: .text='' should remove all child nodes" | ||
| ); | ||
|
|
||
| s1.text = "console.log('test again');"; | ||
| appendDetails("After set .text again: " + JSON.stringify(s1.text)); | ||
| logResult( | ||
| s1.text === "console.log('test again');", | ||
| "Setter: .text can be set multiple times" | ||
| ); | ||
|
|
||
| // Test multiple text nodes case | ||
| const scriptMulti = document.createElement('script'); | ||
| const textNode1 = document.createTextNode('var a = 1;'); | ||
| const textNode2 = document.createTextNode('var b = 2;'); | ||
| const comment = document.createComment('this is a comment'); | ||
|
|
||
| scriptMulti.appendChild(textNode1); | ||
| scriptMulti.appendChild(comment); | ||
| scriptMulti.appendChild(textNode2); | ||
|
|
||
| appendDetails("Multiple text nodes .text: " + JSON.stringify(scriptMulti.text)); | ||
| logResult( | ||
| scriptMulti.text === 'var a = 1;var b = 2;', | ||
| "Getter: .text should concatenate multiple text nodes, ignoring comments" | ||
| ); | ||
| appendDetails("Multiple text nodes .textContent: " + JSON.stringify(scriptMulti.textContent)); | ||
| logResult( | ||
| scriptMulti.textContent === 'var a = 1;var b = 2;', | ||
| "Multiple text nodes: .textContent should equal .text" | ||
| ); | ||
|
|
||
| // Test no text nodes case | ||
| const scriptEmpty = document.createElement('script'); | ||
| const spanElement = document.createElement('span'); | ||
| spanElement.textContent = 'nested content'; | ||
| const commentOnly = document.createComment('only comment'); | ||
|
|
||
| scriptEmpty.appendChild(spanElement); | ||
| scriptEmpty.appendChild(commentOnly); | ||
|
|
||
| appendDetails("No text nodes .text: " + JSON.stringify(scriptEmpty.text)); | ||
| logResult( | ||
| scriptEmpty.text === '', | ||
| "Getter: .text should return empty string when no direct text children" | ||
| ); | ||
| appendDetails("No text nodes .textContent: " + JSON.stringify(scriptEmpty.textContent)); | ||
| logResult( | ||
| scriptEmpty.textContent === 'nested content', | ||
| "No text nodes: .textContent should include nested element content" | ||
| ); | ||
| logResult( | ||
| scriptEmpty.text !== scriptEmpty.textContent, | ||
| "No text nodes: .text should differ from .textContent (spec compliance)" | ||
| ); | ||
|
|
||
| // Test single text node fast path | ||
| const scriptSingle = document.createElement('script'); | ||
| const singleTextNode = document.createTextNode('single text content'); | ||
| scriptSingle.appendChild(singleTextNode); | ||
|
|
||
| appendDetails("Single text node .text: " + JSON.stringify(scriptSingle.text)); | ||
| logResult( | ||
| scriptSingle.text === 'single text content', | ||
| "Getter: .text should handle single text node (fast path)" | ||
| ); | ||
| logResult( | ||
| scriptSingle.text === scriptSingle.textContent, | ||
| "Single text node: .text should equal .textContent" | ||
| ); | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to htmlscriptelement-text.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the test file from script-text-property-test.html to htmlscriptelement-text.html.