Commit f8784b2c authored by Robert Knight's avatar Robert Knight

Remove fragment anchoring support

dom-anchor-fragment is shipped as a UMD module which causes problems on
pages that declare a global function called `define` (see #479).

While we could fix the module, fragment anchoring is not very useful at
the moment. The client primarily anchors to the quote and uses other
anchors only as an optimization. The Wikipedia baseline tests changed in
this PR show how little value a fragment has on real websites.
Therefore, just remove support for generating and using fragment selectors.

This change should not cause anchoring regressions, as anchoring would
only have succeeded previously if the quote selector matched. Now it will just
fall through to anchoring using the range, position or quote selectors instead.

Fixes #479
parent a63ef4a6
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
"diff": "^4.0.1", "diff": "^4.0.1",
"diff-match-patch": "^1.0.0", "diff-match-patch": "^1.0.0",
"document-base-uri": "^1.0.0", "document-base-uri": "^1.0.0",
"dom-anchor-fragment": "^1.0.1",
"dom-anchor-text-position": "^4.0.0", "dom-anchor-text-position": "^4.0.0",
"dom-anchor-text-quote": "^4.0.2", "dom-anchor-text-quote": "^4.0.2",
"dom-node-iterator": "^3.5.3", "dom-node-iterator": "^3.5.3",
...@@ -138,7 +137,6 @@ ...@@ -138,7 +137,6 @@
] ]
}, },
"browser": { "browser": {
"dom-anchor-fragment": "./node_modules/dom-anchor-fragment/dist/FragmentAnchor.js",
"hammerjs": "./node_modules/hammerjs/hammer.js", "hammerjs": "./node_modules/hammerjs/hammer.js",
"jquery": "./node_modules/jquery/dist/jquery.slim.js" "jquery": "./node_modules/jquery/dist/jquery.slim.js"
}, },
......
{ {
FragmentAnchor
RangeAnchor RangeAnchor
TextPositionAnchor TextPositionAnchor
TextQuoteAnchor TextQuoteAnchor
...@@ -40,8 +39,6 @@ exports.anchor = (root, selectors, options = {}) -> ...@@ -40,8 +39,6 @@ exports.anchor = (root, selectors, options = {}) ->
# Collect all the selectors # Collect all the selectors
for selector in selectors ? [] for selector in selectors ? []
switch selector.type switch selector.type
when 'FragmentSelector'
fragment = selector
when 'TextPositionSelector' when 'TextPositionSelector'
position = selector position = selector
options.hint = position.start # TextQuoteAnchor hint options.hint = position.start # TextQuoteAnchor hint
...@@ -61,11 +58,6 @@ exports.anchor = (root, selectors, options = {}) -> ...@@ -61,11 +58,6 @@ exports.anchor = (root, selectors, options = {}) ->
# order, from simple to complex. # order, from simple to complex.
promise = Promise.reject('unable to anchor') promise = Promise.reject('unable to anchor')
if fragment?
promise = promise.catch ->
return querySelector(FragmentAnchor, root, fragment, options)
.then(maybeAssertQuote)
if range? if range?
promise = promise.catch -> promise = promise.catch ->
return querySelector(RangeAnchor, root, range, options) return querySelector(RangeAnchor, root, range, options)
...@@ -85,7 +77,7 @@ exports.anchor = (root, selectors, options = {}) -> ...@@ -85,7 +77,7 @@ exports.anchor = (root, selectors, options = {}) ->
exports.describe = (root, range, options = {}) -> exports.describe = (root, range, options = {}) ->
types = [FragmentAnchor, RangeAnchor, TextPositionAnchor, TextQuoteAnchor] types = [RangeAnchor, TextPositionAnchor, TextQuoteAnchor]
selectors = for type in types selectors = for type in types
try try
......
...@@ -12,11 +12,6 @@ ...@@ -12,11 +12,6 @@
{ {
"source" : "https://en.wikipedia.org/wiki/Regression_testing", "source" : "https://en.wikipedia.org/wiki/Regression_testing",
"selector" : [ "selector" : [
{
"conformsTo" : "https://tools.ietf.org/html/rfc3236",
"value" : "footer-info-lastmod",
"type" : "FragmentSelector"
},
{ {
"endOffset" : 48, "endOffset" : 48,
"endContainer" : "/div[5]/ul[1]/li[1]", "endContainer" : "/div[5]/ul[1]/li[1]",
...@@ -95,11 +90,6 @@ ...@@ -95,11 +90,6 @@
{ {
"source" : "https://en.wikipedia.org/wiki/Regression_testing", "source" : "https://en.wikipedia.org/wiki/Regression_testing",
"selector" : [ "selector" : [
{
"type" : "FragmentSelector",
"conformsTo" : "https://tools.ietf.org/html/rfc3236",
"value" : "mw-content-text"
},
{ {
"endContainer" : "/div[3]/div[3]/div[4]/p[8]", "endContainer" : "/div[3]/div[3]/div[4]/p[8]",
"startContainer" : "/div[3]/div[3]/div[4]/p[8]", "startContainer" : "/div[3]/div[3]/div[4]/p[8]",
...@@ -161,11 +151,6 @@ ...@@ -161,11 +151,6 @@
"target" : [ "target" : [
{ {
"selector" : [ "selector" : [
{
"value" : "mw-content-text",
"conformsTo" : "https://tools.ietf.org/html/rfc3236",
"type" : "FragmentSelector"
},
{ {
"endOffset" : 156, "endOffset" : 156,
"endContainer" : "/div[3]/div[3]/div[4]/blockquote[1]/p[1]", "endContainer" : "/div[3]/div[3]/div[4]/blockquote[1]/p[1]",
...@@ -199,11 +184,6 @@ ...@@ -199,11 +184,6 @@
"target" : [ "target" : [
{ {
"selector" : [ "selector" : [
{
"value" : "mw-content-text",
"conformsTo" : "https://tools.ietf.org/html/rfc3236",
"type" : "FragmentSelector"
},
{ {
"endOffset" : 120, "endOffset" : 120,
"startContainer" : "/div[3]/div[3]/div[4]/p[2]", "startContainer" : "/div[3]/div[3]/div[4]/p[2]",
...@@ -259,11 +239,6 @@ ...@@ -259,11 +239,6 @@
"target" : [ "target" : [
{ {
"selector" : [ "selector" : [
{
"type" : "FragmentSelector",
"value" : "firstHeading",
"conformsTo" : "https://tools.ietf.org/html/rfc3236"
},
{ {
"endOffset" : 18, "endOffset" : 18,
"endContainer" : "/div[3]/h1[1]", "endContainer" : "/div[3]/h1[1]",
......
...@@ -122,6 +122,5 @@ class TextQuoteAnchor ...@@ -122,6 +122,5 @@ class TextQuoteAnchor
exports.RangeAnchor = RangeAnchor exports.RangeAnchor = RangeAnchor
exports.FragmentAnchor = require('dom-anchor-fragment')
exports.TextPositionAnchor = TextPositionAnchor exports.TextPositionAnchor = TextPositionAnchor
exports.TextQuoteAnchor = TextQuoteAnchor exports.TextQuoteAnchor = TextQuoteAnchor
...@@ -3308,11 +3308,6 @@ document-base-uri@^1.0.0: ...@@ -3308,11 +3308,6 @@ document-base-uri@^1.0.0:
resolved "https://registry.yarnpkg.com/document-base-uri/-/document-base-uri-1.0.0.tgz#88013e6ee6aa210f1a991953149f3a1698e1e661" resolved "https://registry.yarnpkg.com/document-base-uri/-/document-base-uri-1.0.0.tgz#88013e6ee6aa210f1a991953149f3a1698e1e661"
integrity sha1-iAE+buaqIQ8amRlTFJ86Fpjh5mE= integrity sha1-iAE+buaqIQ8amRlTFJ86Fpjh5mE=
dom-anchor-fragment@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/dom-anchor-fragment/-/dom-anchor-fragment-1.0.4.tgz#43c9d0596e29dcfda520f4b1d1c1702efc9cdf06"
integrity sha1-Q8nQWW4p3P2lIPSx0cFwLvyc3wY=
dom-anchor-text-position@^4.0.0: dom-anchor-text-position@^4.0.0:
version "4.0.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/dom-anchor-text-position/-/dom-anchor-text-position-4.0.0.tgz#4c839b3bded94f0cab0f06a0189468f3f1ec2bb2" resolved "https://registry.yarnpkg.com/dom-anchor-text-position/-/dom-anchor-text-position-4.0.0.tgz#4c839b3bded94f0cab0f06a0189468f3f1ec2bb2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment