0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-31 11:54:03 -05:00

Use <b>, <i> instead of semantic elements

As the W3C spec says, only use <strong>, <em> if you're sure of the intended
semantics.
This commit is contained in:
Neil Jenkins 2011-11-03 14:18:00 +11:00
parent c83688b630
commit 0bdbef305a

View file

@ -349,7 +349,7 @@ document.addEventListener( 'DOMContentLoaded', function () {
// --- Inline formatting --- // --- Inline formatting ---
// Looks for matching tag and attributes, so won't work // Looks for matching tag and attributes, so won't work
// if <b> instead of <strong> etc. // if <strong> instead of <b> etc.
var hasFormat = function ( tag, attributes, range ) { var hasFormat = function ( tag, attributes, range ) {
// 1. Normalise the arguments and get selection // 1. Normalise the arguments and get selection
tag = tag.toUpperCase(); tag = tag.toUpperCase();
@ -751,13 +751,13 @@ document.addEventListener( 'DOMContentLoaded', function () {
var style = span.style, var style = span.style,
el; el;
if ( style.fontWeight && ( /bold/i.test( style.fontWeight ) ) ) { if ( style.fontWeight && ( /bold/i.test( style.fontWeight ) ) ) {
el = createElement( 'STRONG' ); el = createElement( 'B' );
parent.appendChild( el ); parent.appendChild( el );
parent = el; parent = el;
} }
if ( style.fontStyle && if ( style.fontStyle &&
style.fontStyle.toLowerCase() === 'italic' ) { style.fontStyle.toLowerCase() === 'italic' ) {
el = createElement( 'EM' ); el = createElement( 'I' );
parent.appendChild( el ); parent.appendChild( el );
parent = el; parent = el;
} }
@ -786,13 +786,13 @@ document.addEventListener( 'DOMContentLoaded', function () {
parent.appendChild( el ); parent.appendChild( el );
return el; return el;
}, },
B: function ( b, parent ) { STRONG: function ( _, parent ) {
var el = createElement( 'STRONG' ); var el = createElement( 'B' );
parent.appendChild( el ); parent.appendChild( el );
return el; return el;
}, },
I: function ( i, parent ) { EM: function ( _, parent ) {
var el = createElement( 'EM' ); var el = createElement( 'I' );
parent.appendChild( el ); parent.appendChild( el );
return el; return el;
}, },
@ -1042,7 +1042,7 @@ document.addEventListener( 'DOMContentLoaded', function () {
} }
// Focus cursor // Focus cursor
// If there's a <strong>/<em> etc. at the beginning of the split // If there's a <b>/<i> etc. at the beginning of the split
// make sure we focus inside it. // make sure we focus inside it.
while ( nodeAfterSplit.nodeType === ELEMENT_NODE) { while ( nodeAfterSplit.nodeType === ELEMENT_NODE) {
var child = nodeAfterSplit.firstChild, var child = nodeAfterSplit.firstChild,
@ -1132,8 +1132,8 @@ document.addEventListener( 'DOMContentLoaded', function () {
getRangeAndRemoveBookmark( range ); getRangeAndRemoveBookmark( range );
setSelection( range ); setSelection( range );
}, },
'ctrl-b': mapKeyToFormat( 'STRONG' ), 'ctrl-b': mapKeyToFormat( 'B' ),
'ctrl-i': mapKeyToFormat( 'EM' ), 'ctrl-i': mapKeyToFormat( 'I' ),
'ctrl-u': mapKeyToFormat( 'U' ), 'ctrl-u': mapKeyToFormat( 'U' ),
'ctrl-y': mapKeyTo( redo ), 'ctrl-y': mapKeyTo( redo ),
'ctrl-z': mapKeyTo( undo ), 'ctrl-z': mapKeyTo( undo ),
@ -1294,12 +1294,12 @@ document.addEventListener( 'DOMContentLoaded', function () {
hasFormat: chain( hasFormat ), hasFormat: chain( hasFormat ),
changeFormat: chain( changeFormat ), changeFormat: chain( changeFormat ),
bold: command( changeFormat, { tag: 'STRONG' } ), bold: command( changeFormat, { tag: 'B' } ),
italic: command( changeFormat, { tag: 'EM' } ), italic: command( changeFormat, { tag: 'I' } ),
underline: command( changeFormat, { tag: 'U' } ), underline: command( changeFormat, { tag: 'U' } ),
removeBold: command( changeFormat, null, { tag: 'STRONG' } ), removeBold: command( changeFormat, null, { tag: 'B' } ),
removeItalic: command( changeFormat, null, { tag: 'EM' } ), removeItalic: command( changeFormat, null, { tag: 'I' } ),
removeUnderline: command( changeFormat, null, { tag: 'U' } ), removeUnderline: command( changeFormat, null, { tag: 'U' } ),
makeLink: function ( url ) { makeLink: function ( url ) {