Skip to content

Commit fab0110

Browse files
authored
Set attribute translate="no" to avoid automatic translation
1 parent 9692aa1 commit fab0110

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/display/Display.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export function Display(place, doc, input, options) {
4949
// The element in which the editor lives.
5050
d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror")
5151

52+
// This attribute is respected by automatic translation systems such as Google Translate,
53+
// and may also be respected by tools used by human translators.
54+
d.wrapper.setAttribute('translate', 'no')
55+
5256
// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
5357
if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0 }
5458
if (!webkit && !(gecko && mobile)) d.scroller.draggable = true

test/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,3 +2672,7 @@ testCM("mode_lookahead", function(cm) {
26722672
eq(cm.getTokenAt(Pos(0, 1)).type, null)
26732673
eq(cm.getTokenAt(Pos(1, 1)).type, "atom")
26742674
}, {value: "foo\na\nx\nx\n", mode: "lookahead_mode"})
2675+
2676+
testCM("should has [translate=no]", function (cm) {
2677+
eq(cm.getWrapperElement().getAttribute("translate"), "no")
2678+
}, {})

0 commit comments

Comments
 (0)