-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87ff50b
commit e54c0ba
Showing
7 changed files
with
253 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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
121 changes: 121 additions & 0 deletions
121
test/functional/fixtures/regression/gh-1956/pages/index.html
This file contains 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,121 @@ | ||
<html> | ||
<head><title>Edit test</title></head> | ||
<body> | ||
|
||
<div id="root"></div> | ||
|
||
<script src="https://unpkg.com/react@15/dist/react.js"></script> | ||
<script src="./react-dom.js"></script> | ||
<script src="https://unpkg.com/react-dom@15/dist/react-dom-server.js"></script> | ||
<script src="https://unpkg.com/immutable/dist/immutable.js"></script> | ||
<script src="./slate.js"></script> | ||
<script src="./slate-react.js"></script> | ||
<script> | ||
|
||
// document.addEventListener('keypress', function (event) { | ||
// // alert('keypress') | ||
// }, true); | ||
// | ||
document.addEventListener('textInput', function (event) { | ||
debugger; | ||
modifyInput(event) | ||
// event.preventDefault(); | ||
}, true); | ||
|
||
// document.addEventListener('input', function (event) { | ||
// // debugger | ||
// | ||
// alert('input:' + event.target.innerText) | ||
// }, true); | ||
// | ||
// document.addEventListener('beforeinput', function (event) { | ||
// // alert('beforeinput') | ||
// }, true); | ||
// | ||
// document.onselectionchange = function () { | ||
// // debugger; | ||
// } | ||
// | ||
// function onInput (event) { | ||
// var el = document.getElementById('editor'); | ||
// el.innerHTML = el.innerHTML; | ||
// } | ||
|
||
const initialValue = Slate.Value.fromJSON({ | ||
document: { | ||
nodes: [ | ||
{ | ||
kind: 'block', | ||
type: 'paragraph', | ||
nodes: [ | ||
{ | ||
kind: 'text', | ||
leaves: [ | ||
{ | ||
text: '' | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}) | ||
class App extends React.Component { | ||
constructor() { | ||
super() | ||
this.state = { | ||
value: initialValue | ||
}; | ||
|
||
window.value = () => this.state.value; | ||
} | ||
onChange({value}) { | ||
// debugger | ||
|
||
if(value.selection.anchorOffset === 32) { | ||
debugger; | ||
} | ||
this.setState({value}) | ||
} | ||
render() { | ||
// debugger | ||
return React.createElement(SlateReact.Editor, {value: this.state.value, onChange: this.onChange.bind(this) }) | ||
} | ||
} | ||
ReactDOM.render(React.createElement(App), document.getElementById('root')) | ||
|
||
setInterval(function() { console.log(window.value().selection.anchorOffset) }, 0) | ||
|
||
</script> | ||
|
||
<!--<div data-reactroot="" data-slate-editor="true" data-key="1" contenteditable="true" autocorrect="on" spellcheck="true" role="textbox" data-gramm="false" style="outline: none; white-space: pre-wrap; word-wrap: break-word; -webkit-user-modify: read-write-plaintext-only;"><div data-key="2" style="position: relative;"><span data-key="3"><span data-offset-key="3:0">A line of text in a paragraph.</span></span></div></div>--> | ||
|
||
<style> | ||
div { | ||
/*background-color: red;*/ | ||
} | ||
span { | ||
background-color: yellow; | ||
} | ||
|
||
</style> | ||
|
||
|
||
<div data-reactroot="" data-slate-editor="true" data-key="1a" contenteditable="true" autocorrect="on" spellcheck="true" role="textbox" data-gramm="false" style="outline: none; white-space: pre-wrap; word-wrap: break-word; -webkit-user-modify: read-write-plaintext-only;"><div data-key="2a" style="position: relative;"><span data-key="3a"><span data-offset-key="3:0a">A line of text in a paragraph.</span></span></div></div> | ||
|
||
<div id="editor" style="width: 200px; height: 40px; border: 1px solid black;" contenteditable="true" oninput="onInput(event)"></div> | ||
|
||
input | ||
|
||
<script> | ||
function modifyInput (e) { | ||
debugger | ||
e.target.value += 'bc'; | ||
} | ||
</script> | ||
|
||
<input value="a" type="text"/> | ||
|
||
</body> | ||
</html> |
59 changes: 59 additions & 0 deletions
59
test/functional/fixtures/regression/gh-1956/pages/test.html
This file contains 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,59 @@ | ||
<html> | ||
<head><title>Edit test</title></head> | ||
<script type="text/javascript"> | ||
function onTextInput (event) { | ||
debugger | ||
if (event.target.id === 'input1') | ||
onTextInput1(event); | ||
if (event.target.id === 'input2') | ||
onTextInput2(event); | ||
if (event.target.id === 'input3' || event.target.parentNode.id === 'input3') | ||
onTextInput3(event); | ||
} | ||
|
||
function onTextInput1 (event) { | ||
debugger | ||
event.target.childNodes[0].childNodes[0].nodeValue += event.data; | ||
event.preventDefault(); | ||
} | ||
|
||
function onTextInput2 (event) { | ||
event.target.childNodes[0].nodeValue = 'B' + event.data; | ||
} | ||
|
||
function onTextInput3 (event) { | ||
if (window.preventNextElementReplacement) | ||
return; | ||
|
||
window.preventNextElementReplacement = true; | ||
|
||
var div = document.getElementById('input3'); | ||
var paragraph = div.childNodes[0]; | ||
var textNode = paragraph.childNodes[0]; | ||
var nextParagraph = document.createElement("P"); | ||
|
||
nextParagraph.innerHTML = 'X'; | ||
|
||
div.removeChild(paragraph); | ||
div.appendChild(nextParagraph); | ||
nextParagraph.focus(); | ||
} | ||
|
||
function onInput (event) { | ||
if (event.target.id === 'input1') | ||
throw new Error('Input on `input1` should be prevented'); | ||
|
||
debugger | ||
} | ||
|
||
document.addEventListener('textinput', onTextInput, true); // IE way | ||
document.addEventListener('textInput', onTextInput, true); // Chrome way | ||
document.addEventListener('input', onInput, true); | ||
|
||
</script> | ||
<body> | ||
<div contenteditable="true" id="input1"><p>A</p></div> | ||
<div contenteditable="true" id="input2"><p>B</p></div> | ||
<div contenteditable="true" id="input3"><p>C</p></div> | ||
</body> | ||
</html> |
This file contains 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,5 @@ | ||
describe('[Regression](GH-1956)', function () { | ||
it('Shadow element should not appear in user event handler', function () { | ||
return runTests('testcafe-fixtures/index.js', null, { only: 'chrome' }); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
test/functional/fixtures/regression/gh-1956/testcafe-fixtures/index.js
This file contains 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,19 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture('test') | ||
.page`../pages/test.html`; | ||
|
||
const input1 = Selector('#input1'); | ||
const input3 = Selector('#input3'); | ||
|
||
test('input1', async t => { | ||
await t | ||
.typeText(input1, 'Hello') | ||
.expect(input1.textContent).eql('AHello'); | ||
}); | ||
|
||
test('input3', async t => { | ||
await t | ||
.typeText(input3, 'Hello') | ||
.expect(input3.textContent).eql('HelloX'); | ||
}); |